summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2023-03-17 16:26:16 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2023-03-17 16:26:16 +0200
commite9e0cf67c07291a4934ddcf28560cd63ade3d23c (patch)
treeb46e3bc2afeeea735a8ae42ad8ccd0de586bc584
parent605b8fd8462b17a5681e33a3691b8d4c7bf862a7 (diff)
parent6e58d5ab6a42f22f9c705faea83fbc8889d429c3 (diff)
downloadmariadb-git-bb-11.1-mdev-26137-unsquashed.tar.gz
-rw-r--r--.gitlab-ci.yml5
-rw-r--r--debian/libmariadb-dev.install1
-rw-r--r--debian/mariadb-server-core.install1
-rw-r--r--debian/po/ka.po108
-rw-r--r--extra/comp_err.c23
-rw-r--r--extra/mariabackup/xtrabackup.cc16
-rw-r--r--extra/my_print_defaults.c2
-rw-r--r--include/CMakeLists.txt3
-rw-r--r--include/my_alloca.h45
-rw-r--r--include/my_global.h8
-rw-r--r--include/my_sys.h14
-rw-r--r--include/mysql/service_encryption.h11
-rw-r--r--mysql-test/include/delete_use_source.inc94
-rw-r--r--mysql-test/include/delete_use_source_cases.inc214
-rw-r--r--mysql-test/include/delete_use_source_cases_memory.inc294
-rw-r--r--mysql-test/include/delete_use_source_cases_non_innodb.inc81
-rw-r--r--mysql-test/include/delete_use_source_innodb.inc91
-rw-r--r--mysql-test/include/delete_use_source_memory.inc33
-rw-r--r--mysql-test/include/update_use_source.inc292
-rw-r--r--mysql-test/include/update_use_source_cases.inc183
-rw-r--r--mysql-test/include/update_use_source_ext.inc59
-rw-r--r--mysql-test/main/analyze_stmt_privileges2.result9
-rw-r--r--mysql-test/main/analyze_stmt_privileges2.test15
-rw-r--r--mysql-test/main/delete.result47
-rw-r--r--mysql-test/main/delete.test42
-rw-r--r--mysql-test/main/delete_single_to_multi.result4252
-rw-r--r--mysql-test/main/delete_single_to_multi.test1069
-rw-r--r--mysql-test/main/delete_use_source.result184
-rw-r--r--mysql-test/main/delete_use_source.test120
-rw-r--r--mysql-test/main/delete_use_source_engines.result8870
-rw-r--r--mysql-test/main/delete_use_source_engines.test42
-rw-r--r--mysql-test/main/derived.result333
-rw-r--r--mysql-test/main/derived.test208
-rw-r--r--mysql-test/main/derived_cond_pushdown.result48
-rw-r--r--mysql-test/main/derived_cond_pushdown.test23
-rw-r--r--mysql-test/main/locale.result10
-rw-r--r--mysql-test/main/locale.test15
-rw-r--r--mysql-test/main/log_state.result2
-rw-r--r--mysql-test/main/merge.result12
-rw-r--r--mysql-test/main/merge.test15
-rw-r--r--mysql-test/main/multi_update.result4
-rw-r--r--mysql-test/main/multi_update.test4
-rw-r--r--mysql-test/main/myisam_explain_non_select_all.result36
-rw-r--r--mysql-test/main/opt_trace.result34
-rw-r--r--mysql-test/main/order_by.result8
-rw-r--r--mysql-test/main/partition_charset.result21
-rw-r--r--mysql-test/main/partition_charset.test20
-rw-r--r--mysql-test/main/partition_innodb2.result24
-rw-r--r--mysql-test/main/partition_innodb2.test30
-rw-r--r--mysql-test/main/partition_utf8-debug.result2
-rw-r--r--mysql-test/main/selectivity_innodb.result9
-rw-r--r--mysql-test/main/selectivity_innodb.test9
-rw-r--r--mysql-test/main/subselect.result13
-rw-r--r--mysql-test/main/subselect.test7
-rw-r--r--mysql-test/main/subselect_no_exists_to_in.result13
-rw-r--r--mysql-test/main/subselect_no_mat.result13
-rw-r--r--mysql-test/main/subselect_no_opts.result13
-rw-r--r--mysql-test/main/subselect_no_scache.result13
-rw-r--r--mysql-test/main/subselect_no_semijoin.result13
-rw-r--r--mysql-test/main/update.result40
-rw-r--r--mysql-test/main/update.test38
-rw-r--r--mysql-test/main/update_single_to_multi.result3860
-rw-r--r--mysql-test/main/update_single_to_multi.test832
-rw-r--r--mysql-test/main/update_use_source.result10034
-rw-r--r--mysql-test/main/update_use_source.test252
-rw-r--r--mysql-test/main/variables.result10
-rw-r--r--mysql-test/main/variables.test5
-rw-r--r--mysql-test/main/view_grant.result1
-rw-r--r--mysql-test/main/view_grant.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-key-rotation-disable.test2
-rw-r--r--mysql-test/suite/encryption/t/innodb_encryption_is.test1
-rw-r--r--mysql-test/suite/engines/iuds/r/update_delete_number.result22
-rw-r--r--mysql-test/suite/engines/iuds/t/update_delete_number.test20
-rw-r--r--mysql-test/suite/funcs_1/r/is_collations.result2
-rw-r--r--mysql-test/suite/funcs_1/t/is_collations.test2
-rw-r--r--mysql-test/suite/innodb/r/innodb-system-table-view.result3
-rw-r--r--mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result2
-rw-r--r--mysql-test/suite/innodb/r/innodb_status_variables.result1
-rw-r--r--mysql-test/suite/innodb/r/insert_into_empty.result15
-rw-r--r--mysql-test/suite/innodb/r/online_table_rebuild.result20
-rw-r--r--mysql-test/suite/innodb/r/undo_truncate.result5
-rw-r--r--mysql-test/suite/innodb/t/insert_into_empty.test14
-rw-r--r--mysql-test/suite/innodb/t/online_table_rebuild.test24
-rw-r--r--mysql-test/suite/innodb/t/undo_truncate.opt1
-rw-r--r--mysql-test/suite/innodb/t/undo_truncate.test3
-rw-r--r--mysql-test/suite/innodb_zip/r/page_size,4k.rdiff20
-rw-r--r--mysql-test/suite/innodb_zip/r/page_size,8k.rdiff20
-rw-r--r--mysql-test/suite/innodb_zip/r/page_size.result3
-rw-r--r--mysql-test/suite/innodb_zip/r/restart.result24
-rw-r--r--mysql-test/suite/json/r/json_table.result101
-rw-r--r--mysql-test/suite/json/t/json_table.test94
-rw-r--r--mysql-test/suite/parts/t/engine_defined_part_attributes.test5
-rw-r--r--mysql-test/suite/period/r/update.result2
-rw-r--r--mysql-test/suite/period/t/update.test2
-rw-r--r--mysql-test/suite/plugins/r/locales.result2
-rw-r--r--mysql-test/suite/sys_vars/r/lc_time_names_basic.result6
-rw-r--r--mysql-test/suite/sys_vars/t/lc_time_names_basic.test4
-rw-r--r--mysys/my_init.c12
-rw-r--r--mysys/my_symlink.c4
-rw-r--r--plugin/cracklib_password_check/cracklib_password_check.c2
-rw-r--r--plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp5
-rw-r--r--plugin/handler_socket/libhsclient/allocator.hpp1
-rw-r--r--scripts/mysql_install_db.sh24
-rw-r--r--sql/derror.cc2
-rw-r--r--sql/field.h10
-rw-r--r--sql/ha_partition.cc13
-rw-r--r--sql/handler.h5
-rw-r--r--sql/item.h23
-rw-r--r--sql/item_subselect.cc4
-rw-r--r--sql/json_table.cc5
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/opt_split.cc7
-rw-r--r--sql/opt_subselect.cc54
-rw-r--r--sql/share/CMakeLists.txt1
-rw-r--r--sql/share/errmsg-utf8.txt706
-rw-r--r--sql/sql_base.cc73
-rw-r--r--sql/sql_base.h15
-rw-r--r--sql/sql_class.h5
-rw-r--r--sql/sql_cmd.h207
-rw-r--r--sql/sql_delete.cc678
-rw-r--r--sql/sql_delete.h82
-rw-r--r--sql/sql_lex.cc62
-rw-r--r--sql/sql_lex.h31
-rw-r--r--sql/sql_locale.cc49
-rw-r--r--sql/sql_parse.cc261
-rw-r--r--sql/sql_parse.h1
-rw-r--r--sql/sql_prepare.cc247
-rw-r--r--sql/sql_select.cc277
-rw-r--r--sql/sql_table.cc221
-rw-r--r--sql/sql_type.cc42
-rw-r--r--sql/sql_type.h27
-rw-r--r--sql/sql_type_fixedbin.h4
-rw-r--r--sql/sql_type_geom.cc3
-rw-r--r--sql/sql_type_geom.h3
-rw-r--r--sql/sql_update.cc710
-rw-r--r--sql/sql_update.h89
-rw-r--r--sql/sql_yacc.yy103
-rw-r--r--sql/table.cc10
-rw-r--r--sql/table.h1
-rw-r--r--sql/temporary_tables.cc13
-rw-r--r--storage/connect/mysql-test/connect/r/upd.result156
-rw-r--r--storage/connect/mysql-test/connect/t/upd.test96
-rw-r--r--storage/innobase/btr/btr0btr.cc147
-rw-r--r--storage/innobase/btr/btr0cur.cc157
-rw-r--r--storage/innobase/buf/buf0buf.cc178
-rw-r--r--storage/innobase/buf/buf0dblwr.cc66
-rw-r--r--storage/innobase/buf/buf0flu.cc1004
-rw-r--r--storage/innobase/buf/buf0lru.cc99
-rw-r--r--storage/innobase/buf/buf0rea.cc103
-rw-r--r--storage/innobase/fil/fil0fil.cc43
-rw-r--r--storage/innobase/gis/gis0rtree.cc4
-rw-r--r--storage/innobase/handler/ha_innodb.cc94
-rw-r--r--storage/innobase/handler/handler0alter.cc1
-rw-r--r--storage/innobase/handler/i_s.cc9
-rw-r--r--storage/innobase/include/btr0btr.h2
-rw-r--r--storage/innobase/include/btr0types.h3
-rw-r--r--storage/innobase/include/buf0buf.h205
-rw-r--r--storage/innobase/include/buf0dblwr.h69
-rw-r--r--storage/innobase/include/buf0flu.h22
-rw-r--r--storage/innobase/include/buf0rea.h1
-rw-r--r--storage/innobase/include/fil0fil.h57
-rw-r--r--storage/innobase/include/mtr0mtr.h3
-rw-r--r--storage/innobase/include/srv0srv.h17
-rw-r--r--storage/innobase/include/trx0sys.h11
-rw-r--r--storage/innobase/include/trx0trx.h4
-rw-r--r--storage/innobase/lock/lock0lock.cc68
-rw-r--r--storage/innobase/log/log0log.cc8
-rw-r--r--storage/innobase/log/log0recv.cc2
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc4
-rw-r--r--storage/innobase/rem/rem0rec.cc183
-rw-r--r--storage/innobase/row/row0ins.cc2
-rw-r--r--storage/innobase/row/row0log.cc6
-rw-r--r--storage/innobase/srv/srv0mon.cc12
-rw-r--r--storage/innobase/srv/srv0srv.cc48
-rw-r--r--storage/innobase/srv/srv0start.cc13
-rw-r--r--storage/innobase/trx/trx0roll.cc6
-rw-r--r--storage/innobase/trx/trx0trx.cc1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result2
-rw-r--r--storage/spider/mysql-test/spider/r/error_row_number.result2
-rwxr-xr-xsupport-files/mini-benchmark.sh27
180 files changed, 35923 insertions, 3779 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2639fc579d7..8c2b4ae363d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -331,6 +331,7 @@ mysql-test-run-asan:
needs:
- "fedora-sanitizer: [-DWITH_ASAN=YES]"
<<: *mysql-test-run-def
+ allow_failure: true
artifacts:
when: always # Also show results when tests fail
reports:
@@ -489,6 +490,8 @@ mini-benchmark:
stage: test
dependencies:
- fedora
+ needs:
+ - fedora
script:
- ls -la rpm; rm -vf rpm/*.el?.* # Delete artifacts from Centos builds
# Don't use cracklib, otherwise the Sysbench user password will be rejected
@@ -503,7 +506,7 @@ mini-benchmark:
- |
mariadb --skip-column-names -e "SELECT @@version, @@version_comment" | tee /tmp/version
grep $MARIADB_MAJOR_VERSION /tmp/version || echo "MariaDB didn't install properly"
- - yum install -y sysbench procps-ng perf || yum install -y https://kojipkgs.fedoraproject.org//packages/luajit/2.0.4/3.el7/x86_64/luajit-2.0.4-3.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/sysbench/1.0.17/2.el7/x86_64/sysbench-1.0.17-2.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/ck/0.5.2/2.el7/x86_64/ck-0.5.2-2.el7.x86_64.rpm
+ - yum install -y sysbench procps-ng perf util-linux || yum install -y https://kojipkgs.fedoraproject.org//packages/luajit/2.0.4/3.el7/x86_64/luajit-2.0.4-3.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/sysbench/1.0.17/2.el7/x86_64/sysbench-1.0.17-2.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/ck/0.5.2/2.el7/x86_64/ck-0.5.2-2.el7.x86_64.rpm
- /usr/share/mysql/mini-benchmark
- cp -av */sysbench-run-*.log */metrics.txt .. # Move files one level down so they can be saved as artifacts
artifacts:
diff --git a/debian/libmariadb-dev.install b/debian/libmariadb-dev.install
index 9b49e9ad0d4..0f82ac68d7d 100644
--- a/debian/libmariadb-dev.install
+++ b/debian/libmariadb-dev.install
@@ -15,6 +15,7 @@ usr/include/mariadb/mariadb_version.h
usr/include/mariadb/my_config.h
usr/include/mariadb/my_global.h
usr/include/mariadb/my_sys.h
+usr/include/mariadb/my_alloca.h
usr/include/mariadb/mysql.h
usr/include/mariadb/mysql/
usr/include/mariadb/mysql/client_plugin.h
diff --git a/debian/mariadb-server-core.install b/debian/mariadb-server-core.install
index dbfa6246ee1..d61c42c77c4 100644
--- a/debian/mariadb-server-core.install
+++ b/debian/mariadb-server-core.install
@@ -19,6 +19,7 @@ usr/share/mysql/estonian
usr/share/mysql/fill_help_tables.sql
usr/share/mysql/french
usr/share/mysql/german
+usr/share/mysql/georgian
usr/share/mysql/greek
usr/share/mysql/hindi
usr/share/mysql/hungarian
diff --git a/debian/po/ka.po b/debian/po/ka.po
new file mode 100644
index 00000000000..b0e8058b3c2
--- /dev/null
+++ b/debian/po/ka.po
@@ -0,0 +1,108 @@
+# Translation of ka.po to Georgian
+# Copyright (C) 2023, MariaDB authors.
+# This file is distributed under the same license as the mariadb package.
+# Ekaterine Papava <papava.e@gtu.ge>, 2023.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: mariadb\n"
+"Report-Msgid-Bugs-To: mariadb@packages.debian.org\n"
+"POT-Creation-Date: 2019-07-23 19:16-0300\n"
+"PO-Revision-Date: 2023-03-04 05:18+0100\n"
+"Last-Translator: Ekaterine Papava <papava.e@gtu.ge>\n"
+"Language-Team: Georgian <(nothing)>\n"
+"Language: ka\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Poedit 3.2.2\n"
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:2001
+msgid "The old data directory will be saved at new location"
+msgstr "ძველი მონაცემების საქაღალდე ახალ მდებარეობაზე იქნება შენახული"
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:2001
+msgid ""
+"A file named /var/lib/mysql/debian-*.flag exists on this system. The number "
+"indicates a database binary format version that cannot automatically be "
+"upgraded (or downgraded)."
+msgstr ""
+"ამ სისტემაში არსებობს ფაილი სახელით /var/lib/mysql/debian-*.flag. რიცხვი "
+"მიუთითებს ბაზის ბინარული ფორმატის ვერსიაზე, რომლის განახლება (ან ვერსიის "
+"ჩამოწევა) შეუძლებელია."
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:2001
+msgid ""
+"Therefore the previous data directory will be renamed to /var/lib/mysql-* "
+"and a new data directory will be initialized at /var/lib/mysql."
+msgstr ""
+"ამიტომ წინა მონაცემების საქაღალდეს სახელი /var/lib/mysql-*-ზე გადაერქმევა "
+"და /var/lib/mysql მონაცემების საქაღალდე თავიდან შეიქმნება."
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:2001
+msgid ""
+"Please manually export/import your data (e.g. with mysqldump) if needed."
+msgstr ""
+"საჭიროების შემთხვევაში თქვენი მონაცემები ხელით გაიტანეთ/შემოიტანეთ (მაგ: "
+"mysqldump-ით)."
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:3001
+msgid "Important note for NIS/YP users"
+msgstr "მნიშვნელოვანი შენიშვნა NIS/YP მომხმარებლებისთვის"
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:3001
+msgid ""
+"Using MariaDB under NIS/YP requires a mysql user account to be added on the "
+"local system with:"
+msgstr ""
+"MariaDB-ის გამოყენება NIS/YP-ის ქვეშ გასაშვებად მოითხოვს ლოკალურ სისტემაში "
+"mysql-ის მომხმარებლის დამატებას შემდეგი პარამეტრებით:"
+
+#. Type: note
+#. Description
+#: ../mariadb-server.templates:3001
+msgid ""
+"You should also check the permissions and ownership of the /var/lib/mysql "
+"directory:"
+msgstr "ასევე შეამოწმეთ /var/lib/mysql საქაღალდის წვდომები და მფლობელი:"
+
+#. Type: boolean
+#. Description
+#: ../mariadb-server.templates:4001
+msgid "Remove all MariaDB databases?"
+msgstr "წავშალო MariaDB-ის ყველა ბაზა?"
+
+#. Type: boolean
+#. Description
+#: ../mariadb-server.templates:4001
+msgid ""
+"The /var/lib/mysql directory which contains the MariaDB databases is about "
+"to be removed."
+msgstr ""
+"საქაღალდე /var/lib/mysql, რომელიც MariaDB-ის მონაცემთა ბაზებს შეიცავს, "
+"წაიშლება."
+
+#. Type: boolean
+#. Description
+#: ../mariadb-server.templates:4001
+msgid ""
+"If you're removing the MariaDB package in order to later install a more "
+"recent version or if a different mariadb-server package is already using it, "
+"the data should be kept."
+msgstr ""
+"თუ შლით MariaDB-ის პაკეტს იმისთვის, რომ მოგვიანებით უფრო ახალი ვერსია "
+"დააყენოთ ან mariadb-server-ის სხვა პაკეტი უკვე იყენებს მას, მონაცემები უნდა "
+"შენარჩუნდეს."
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 40562aeae5d..455f0d3c0d9 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -37,7 +37,7 @@
#define ERRORS_PER_RANGE 1000
#define MAX_SECTIONS 4
#define HEADER_LENGTH 32 /* Length of header in errmsg.sys */
-#define ERRMSG_VERSION 4 /* Version number of errmsg.sys */
+#define ERRMSG_VERSION 5 /* Version number of errmsg.sys */
#define DEFAULT_CHARSET_DIR "../sql/share/charsets"
#define ER_PREFIX "ER_"
#define ER_PREFIX2 "MARIA_ER_"
@@ -85,7 +85,6 @@ struct languages
{
char *lang_long_name; /* full name of the language */
char *lang_short_name; /* abbreviation of the lang. */
- char *charset; /* Character set name */
struct languages *next_lang; /* Pointer to next language */
};
@@ -329,7 +328,7 @@ static int create_sys_files(struct languages *lang_head,
uint error_count)
{
FILE *to;
- uint csnum= 0, i, row_nr;
+ uint i, row_nr;
ulong length;
uchar head[HEADER_LENGTH];
char outfile[FN_REFLEN], *outfile_end;
@@ -345,16 +344,6 @@ static int create_sys_files(struct languages *lang_head,
*/
for (tmp_lang= lang_head; tmp_lang; tmp_lang= tmp_lang->next_lang)
{
-
- /* setting charset name */
- if (!(csnum= get_charset_number(tmp_lang->charset, MY_CS_PRIMARY,
- MYF(MY_UTF8_IS_UTF8MB3))))
- {
- fprintf(stderr, "Unknown charset '%s' in '%s'\n", tmp_lang->charset,
- TXTFILE);
- DBUG_RETURN(1);
- }
-
outfile_end= strxmov(outfile, DATADIRECTORY,
tmp_lang->lang_long_name, NullS);
if (!my_stat(outfile, &stat_info,MYF(0)))
@@ -410,7 +399,6 @@ static int create_sys_files(struct languages *lang_head,
int2store(head + 10, max_error); /* Max error */
int2store(head + 12, row_nr);
int2store(head + 14, section_count);
- head[30]= csnum;
my_fseek(to, 0l, MY_SEEK_SET, MYF(0));
if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP)) ||
@@ -450,7 +438,6 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
next_language= tmp_lang->next_lang;
my_free(tmp_lang->lang_short_name);
my_free(tmp_lang->lang_long_name);
- my_free(tmp_lang->charset);
my_free(tmp_lang);
}
@@ -1113,12 +1100,6 @@ static struct languages *parse_charset_string(char *str)
DBUG_RETURN(0); /* OOM: Fatal error */
DBUG_PRINT("info", ("short_name: %s", new_lang->lang_short_name));
- /* getting the charset name */
- str= skip_delimiters(str);
- if (!(new_lang->charset= get_word(&str)))
- DBUG_RETURN(0); /* Fatal error */
- DBUG_PRINT("info", ("charset: %s", new_lang->charset));
-
/* skipping space, tab or "," */
str= skip_delimiters(str);
}
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 724f2463ff6..1811415cd2a 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -2270,8 +2270,14 @@ static bool innodb_init()
/* Check if the data files exist or not. */
dberr_t err= srv_sys_space.check_file_spec(&create_new_db, 5U << 20);
+ if (create_new_db)
+ {
+ msg("mariadb-backup: InnoDB files do not exist");
+ return true;
+ }
+
if (err == DB_SUCCESS)
- err= srv_start(create_new_db);
+ err= srv_start(false);
if (err != DB_SUCCESS)
{
@@ -2282,6 +2288,7 @@ static bool innodb_init()
ut_ad(srv_force_recovery <= SRV_FORCE_IGNORE_CORRUPT);
ut_ad(recv_no_log_write);
buf_flush_sync();
+ recv_sys.debug_free();
DBUG_ASSERT(!buf_pool.any_io_pending());
log_sys.close_file();
@@ -3497,7 +3504,9 @@ static void xb_load_single_table_tablespace(const char *dirname,
if (err == DB_SUCCESS && file->space_id() != SRV_TMP_SPACE_ID) {
space = fil_space_t::create(
file->space_id(), file->flags(),
- FIL_TYPE_TABLESPACE, NULL/* TODO: crypt_data */);
+ FIL_TYPE_TABLESPACE, nullptr/* TODO: crypt_data */,
+ FIL_ENCRYPTION_DEFAULT,
+ file->handle() != OS_FILE_CLOSED);
ut_a(space != NULL);
fil_node_t* node= space->add(
@@ -5217,7 +5226,8 @@ exit:
ut_ad(fil_space_t::physical_size(flags) == info.page_size);
if (fil_space_t::create(info.space_id, flags,
- FIL_TYPE_TABLESPACE, 0)) {
+ FIL_TYPE_TABLESPACE, 0, FIL_ENCRYPTION_DEFAULT,
+ true)) {
*success = xb_space_create_file(real_name, info.space_id,
flags, &file);
} else {
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 6aa60aa8ce8..6fc9f3f4d9b 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -51,6 +51,8 @@ static struct my_option my_long_options[] =
#endif
{"mysqld", 0, "Read the same set of groups that the mysqld binary does.",
&opt_mysqld, &opt_mysqld, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"mariadbd", 0, "Read the same set of groups that the mariadbd binary does.",
+ &opt_mysqld, &opt_mysqld, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"no-defaults", 'n', "Return an empty string (useful for scripts).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help message and exit.",
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 1024821e569..a82d1143649 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -37,6 +37,7 @@ SET(HEADERS
ma_dyncol.h
my_list.h
my_alloc.h
+ my_alloca.h
typelib.h
my_dbug.h
m_string.h
@@ -111,7 +112,9 @@ ${footer}
ENDMACRO()
INSTALL_COMPAT_HEADER(my_global.h "")
+INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_config.h "")
+INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_sys.h "")
INSTALL_COMPAT_HEADER(mysql_version.h "
#include <mariadb_version.h>
diff --git a/include/my_alloca.h b/include/my_alloca.h
new file mode 100644
index 00000000000..761c2adb890
--- /dev/null
+++ b/include/my_alloca.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2023, MariaDB Corporation.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#ifndef MY_ALLOCA_INCLUDED
+#define MY_ALLOCA_INCLUDED
+
+#ifdef _WIN32
+#include <malloc.h> /*for alloca*/
+/*
+ MSVC may define "alloca" when compiling in /Ze mode
+ (with extensions from Microsoft), but otherwise only
+ the _alloca function is defined:
+*/
+#ifndef alloca
+#define alloca _alloca
+#endif
+#else
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#endif
+
+#if defined(HAVE_ALLOCA)
+/*
+ If the GCC/LLVM compiler from the MinGW is used,
+ alloca may not be defined when using the MSVC CRT:
+*/
+#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && !defined(alloca)
+#define alloca __builtin_alloca
+#endif /* GNUC */
+#endif
+
+#endif /* MY_ALLOCA_INCLUDED */
diff --git a/include/my_global.h b/include/my_global.h
index 730139be5f2..952e65c9728 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -330,13 +330,6 @@ C_MODE_END
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
-#undef HAVE_ALLOCA
-#undef HAVE_ALLOCA_H
-#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
#include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */
@@ -493,6 +486,7 @@ typedef unsigned short ushort;
#endif
#include <my_compiler.h>
+#include <my_alloca.h>
/*
Wen using the embedded library, users might run into link problems,
diff --git a/include/my_sys.h b/include/my_sys.h
index f52510d629e..3180a8c37da 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -28,9 +28,7 @@ C_MODE_START
#include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h>
#include <typelib.h>
-#ifdef _WIN32
-#include <malloc.h> /*for alloca*/
-#endif
+#include <my_alloca.h>
#include <mysql/plugin.h>
#include <mysql/service_my_print_error.h>
@@ -195,16 +193,6 @@ my_bool my_test_if_thinly_provisioned(File handle);
extern my_bool my_may_have_atomic_write;
#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind)
-#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
-#pragma alloca
-#endif /* _AIX */
-#if defined(__MWERKS__)
-#undef alloca
-#define alloca _alloca
-#endif /* __MWERKS__ */
-#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
-#define alloca __builtin_alloca
-#endif /* GNUC */
#define my_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) ((void)0)
#define MAX_ALLOCA_SZ 4096
diff --git a/include/mysql/service_encryption.h b/include/mysql/service_encryption.h
index 69d205a27e8..280b9c69e35 100644
--- a/include/mysql/service_encryption.h
+++ b/include/mysql/service_encryption.h
@@ -24,22 +24,19 @@
*provider* (encryption plugin).
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef MYSQL_ABI_CHECK
+#include <my_alloca.h>
#ifdef _WIN32
-#include <malloc.h>
#ifndef __cplusplus
#define inline __inline
#endif
#else
#include <stdlib.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
#endif
#endif
+
+#ifdef __cplusplus
+extern "C" {
#endif
/* returned from encryption_key_get_latest_version() */
diff --git a/mysql-test/include/delete_use_source.inc b/mysql-test/include/delete_use_source.inc
new file mode 100644
index 00000000000..3f789767142
--- /dev/null
+++ b/mysql-test/include/delete_use_source.inc
@@ -0,0 +1,94 @@
+create table t1 (c1 integer, c2 integer, c3 integer);
+
+insert into t1(c1,c2,c3)
+ values (1,1,1),(1,2,2),(1,3,3),
+ (2,1,4),(2,2,5),(2,3,6),
+ (2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+
+create view v1 as select * from t1 where c2=2;
+
+--echo #######################################
+--echo # Test without any index #
+--echo #######################################
+--source include/delete_use_source_cases.inc
+--source include/delete_use_source_cases_non_innodb.inc
+
+--echo #######################################
+--echo # Test with an index #
+--echo #######################################
+create index t1_c2 on t1 (c2,c1);
+--source include/delete_use_source_cases.inc
+--source include/delete_use_source_cases_non_innodb.inc
+
+--echo #######################################
+--echo # Test with a primary key #
+--echo #######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+--source include/delete_use_source_cases.inc
+--source include/delete_use_source_cases_non_innodb.inc
+
+drop view v1;
+drop table t1;
+
+--echo #
+--echo # Test on dynamic columns (blob)
+--echo #
+create table assets (
+ item_name varchar(32) primary key, -- A common attribute for all items
+ dynamic_cols blob -- Dynamic columns will be stored here
+);
+
+INSERT INTO assets
+ VALUES ('MariaDB T-shirt',
+ COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets
+ VALUES ('Thinkpad Laptop',
+ COLUMN_CREATE('color', 'black', 'price', 500));
+INSERT INTO assets
+ VALUES ('Fridge',
+ COLUMN_CREATE('color', 'white', 'warranty', '5 years'));
+INSERT INTO assets
+ VALUES ('Microwave',
+ COLUMN_CREATE('warranty', '3 years'));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+UPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, 'color')
+ WHERE item_name='Fridge';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+DELETE FROM assets
+ WHERE item_name in
+ (select b.item_name from assets b
+ where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+DELETE FROM assets WHERE item_name='Microwave';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+drop table assets ;
+
+
+--echo #
+--echo # Test on fulltext columns
+--echo #
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+ ('MySQL vs MariaDB database'),
+ ('Oracle vs MariaDB database'),
+ ('PostgreSQL vs MariaDB database'),
+ ('MariaDB overview'),
+ ('Foreign keys'),
+ ('Primary keys'),
+ ('Indexes'),
+ ('Transactions'),
+ ('Triggers');
+
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+DELETE FROM ft2 WHERE MATCH(copy) AGAINST('database');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+drop table ft2;
+
diff --git a/mysql-test/include/delete_use_source_cases.inc b/mysql-test/include/delete_use_source_cases.inc
new file mode 100644
index 00000000000..24408b7dd50
--- /dev/null
+++ b/mysql-test/include/delete_use_source_cases.inc
@@ -0,0 +1,214 @@
+--echo #
+--echo # Delete with value from subquery on the same table
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with EXISTS subquery over the updated table
+--echo # in WHERE + possibly sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+eval analyze $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with IN predicand over the updated table in WHERE
+--echo #
+let $c = c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with a limit - can be deleted
+--echo #
+let $c = c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+eval analyze $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with a limit and an order by
+--echo #
+
+let $c = c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete: 2 execution of PS
+--echo #
+
+prepare create_tmp_stmt from
+ "create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+ "delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+--sorted_result
+select * from t1;
+
+prepare insert_tmp_stmt from
+ "insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+--sorted_result
+select * from t1;
+
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+--sorted_result
+select * from t1;
+
+drop table tmp;
+
+--echo #
+--echo # Delete in stored procedure
+--echo #
+
+delimiter //;
+create procedure sp()
+begin
+ delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+end
+//
+delimiter ;//
+
+create table tmp as select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+
+--echo #
+--echo # Delete in stored function
+--echo #
+delimiter //;
+create function f1(IN a INT) returns int
+begin
+ delete from t1 where c3 < a order by c3 limit 1;
+ return 1;
+end;//
+delimiter ;//
+
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+ order by c3 limit 1;
+select f1(@a);
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+ order by c3 limit 1;
+select f1(@a);
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+
+--echo #
+--echo # Delete in trigger
+--echo #
+
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+ UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+ DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+--enable_info ONCE
+DELETE FROM t1 WHERE c2>=3;
+
+--sorted_result
+select * from t1;
+--sorted_result
+SELECT * FROM t2;
+SELECT * FROM cnt;
+
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+
+--echo #
+--echo # Delete with a reference to view in subquery
+--echo #
+let $c = t1.c2 in ( select max(a.c2) from v1 a
+ where a.c1 = t1.c1);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+eval analyze $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
diff --git a/mysql-test/include/delete_use_source_cases_memory.inc b/mysql-test/include/delete_use_source_cases_memory.inc
new file mode 100644
index 00000000000..7a61b59e2a5
--- /dev/null
+++ b/mysql-test/include/delete_use_source_cases_memory.inc
@@ -0,0 +1,294 @@
+--echo #
+--echo # Delete with value from subquery on the same table
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with EXISTS subquery over the updated table
+--echo # in WHERE + possibly sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with EXISTS subquery over the updated table
+--echo # in WHERE + non-sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with order by
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2)
+ and c2 >= 3 order by c2;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with IN predicand over the updated table in WHERE
+--echo #
+let $c = c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with a limit - can be deleted
+--echo #
+let $c = c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with a limit and an order by
+--echo #
+
+let $c = c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete: 2 execution of PS
+--echo #
+
+prepare create_tmp_stmt from
+ "create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+ "delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+--sorted_result
+select * from t1;
+
+prepare insert_tmp_stmt from
+ "insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+--sorted_result
+select * from t1;
+
+drop table tmp;
+
+--echo #
+--echo # Delete in stored procedure
+--echo #
+
+delimiter //;
+create procedure sp()
+begin
+ delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+end
+//
+delimiter ;//
+
+create table tmp as select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+ where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 1;
+CALL sp;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+
+--echo #
+--echo # Delete in stored function
+--echo #
+delimiter //;
+create function f1(IN a INT) returns int
+begin
+ delete from t1 where c3 < a order by c3 limit 1;
+ return 1;
+end;//
+delimiter ;//
+
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+ order by c3 limit 1;
+select f1(@a);
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+ order by c3 limit 1;
+select f1(@a);
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+
+--echo #
+--echo # Delete in trigger
+--echo #
+
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+ UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+ DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+--enable_info ONCE
+DELETE FROM t1 WHERE c2>=3;
+
+--sorted_result
+select * from t1;
+--sorted_result
+SELECT * FROM t2;
+SELECT * FROM cnt;
+
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+
+--echo #
+--echo Delete with a reference to view in subquery
+--echo #
+let $c = t1.c2 in ( select max(a.c2) from v1 a
+ where a.c1 = t1.c1);
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete from view
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = v1.c1 in
+ (select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+eval create table tmp as select * from v1 where $c;
+let $q = delete from v1 where $c;
+eval explain select * from v1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete from view using reference
+--echo # to the same view in subquery
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+ and c1 = 2
+ and exists (select 'X' from v1 a where a.c1 = v1.c1);
+eval create table tmp as select * from v1 where $c;
+let $q = delete from v1 where $c;
+eval explain select * from v1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
diff --git a/mysql-test/include/delete_use_source_cases_non_innodb.inc b/mysql-test/include/delete_use_source_cases_non_innodb.inc
new file mode 100644
index 00000000000..caa581716dc
--- /dev/null
+++ b/mysql-test/include/delete_use_source_cases_non_innodb.inc
@@ -0,0 +1,81 @@
+--echo #
+--echo # Delete with EXISTS subquery over the updated table
+--echo # in WHERE + non-sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete with order by
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2)
+ and c2 >= 3 order by c2;
+eval create table tmp as select * from t1 where $c;
+let $q = delete from t1 where $c;
+--replace_column 9 #
+eval explain select * from t1 where $c;
+--replace_column 9 #
+eval explain $q;
+--replace_column 9 #
+eval analyze $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete from view
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = v1.c1 in
+ (select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+eval create table tmp as select * from v1 where $c;
+let $q = delete from v1 where $c;
+eval explain select * from v1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+
+--echo #
+--echo # Delete from view using reference
+--echo # to the same view in subquery
+--echo #
+
+analyze table t1 persistent for all;
+
+let $c = v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+ and c1 = 2
+ and exists (select 'X' from v1 a where a.c1 = v1.c1);
+eval create table tmp as select * from v1 where $c;
+let $q = delete from v1 where $c;
+--replace_column 9 #
+eval explain select * from v1 where $c;
+--replace_column 9 #
+eval explain $q;
+--replace_column 9 #
+eval analyze $q;
+--sorted_result
+select * from t1;
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
diff --git a/mysql-test/include/delete_use_source_innodb.inc b/mysql-test/include/delete_use_source_innodb.inc
new file mode 100644
index 00000000000..83915d47656
--- /dev/null
+++ b/mysql-test/include/delete_use_source_innodb.inc
@@ -0,0 +1,91 @@
+create table t1 (c1 integer, c2 integer, c3 integer);
+
+insert into t1(c1,c2,c3)
+ values (1,1,1),(1,2,2),(1,3,3),
+ (2,1,4),(2,2,5),(2,3,6),
+ (2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+
+create view v1 as select * from t1 where c2=2;
+
+--echo #######################################
+--echo # Test without any index #
+--echo #######################################
+--source include/delete_use_source_cases.inc
+
+--echo #######################################
+--echo # Test with an index #
+--echo #######################################
+create index t1_c2 on t1 (c2,c1);
+--source include/delete_use_source_cases.inc
+
+--echo #######################################
+--echo # Test with a primary key #
+--echo #######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+--source include/delete_use_source_cases.inc
+
+drop view v1;
+drop table t1;
+
+--echo #
+--echo # Test on dynamic columns (blob)
+--echo #
+create table assets (
+ item_name varchar(32) primary key, -- A common attribute for all items
+ dynamic_cols blob -- Dynamic columns will be stored here
+);
+
+INSERT INTO assets
+ VALUES ('MariaDB T-shirt',
+ COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets
+ VALUES ('Thinkpad Laptop',
+ COLUMN_CREATE('color', 'black', 'price', 500));
+INSERT INTO assets
+ VALUES ('Fridge',
+ COLUMN_CREATE('color', 'white', 'warranty', '5 years'));
+INSERT INTO assets
+ VALUES ('Microwave',
+ COLUMN_CREATE('warranty', '3 years'));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+UPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, 'color')
+ WHERE item_name='Fridge';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+DELETE FROM assets
+ WHERE item_name in
+ (select b.item_name from assets b
+ where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+DELETE FROM assets WHERE item_name='Microwave';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets ORDER BY item_name;
+drop table assets ;
+
+
+--echo #
+--echo # Test on fulltext columns
+--echo #
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+ ('MySQL vs MariaDB database'),
+ ('Oracle vs MariaDB database'),
+ ('PostgreSQL vs MariaDB database'),
+ ('MariaDB overview'),
+ ('Foreign keys'),
+ ('Primary keys'),
+ ('Indexes'),
+ ('Transactions'),
+ ('Triggers');
+
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+DELETE FROM ft2 WHERE MATCH(copy) AGAINST('database');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+drop table ft2;
+
diff --git a/mysql-test/include/delete_use_source_memory.inc b/mysql-test/include/delete_use_source_memory.inc
new file mode 100644
index 00000000000..dbaae1a6120
--- /dev/null
+++ b/mysql-test/include/delete_use_source_memory.inc
@@ -0,0 +1,33 @@
+create table t1 (c1 integer, c2 integer, c3 integer);
+
+insert into t1(c1,c2,c3)
+ values (1,1,1),(1,2,2),(1,3,3),
+ (2,1,4),(2,2,5),(2,3,6),
+ (2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+
+create view v1 as select * from t1 where c2=2;
+
+--echo #######################################
+--echo # Test without any index #
+--echo #######################################
+--source include/delete_use_source_cases_memory.inc
+
+--echo #######################################
+--echo # Test with an index #
+--echo #######################################
+create index t1_c2 on t1 (c2,c1);
+--source include/delete_use_source_cases_memory.inc
+
+--echo #######################################
+--echo # Test with a primary key #
+--echo #######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+--source include/delete_use_source_cases_memory.inc
+
+drop view v1;
+drop table t1;
+
diff --git a/mysql-test/include/update_use_source.inc b/mysql-test/include/update_use_source.inc
index 3c487704233..e1b66d2b996 100644
--- a/mysql-test/include/update_use_source.inc
+++ b/mysql-test/include/update_use_source.inc
@@ -1,150 +1,188 @@
# Include to test update with same table as source and target
---echo #
---echo # Update a with value from subquery on the same table, no search clause. ALL access
---echo #
-
-#Enable view protocol after fix MDEV-29207
---disable_view_protocol
-start transaction;
+create table t1 (old_c1 integer,
+ old_c2 integer,
+ c1 integer,
+ c2 integer,
+ c3 integer);
+
+create view v1 as select * from t1 where c2=2;
+delimiter /;
+create trigger trg_t1 before update on t1 for each row
+begin
+ set new.old_c1=old.c1;
+ set new.old_c2=old.c2;
+end;
+/
+delimiter ;/
+
+insert into t1(c1,c2,c3)
+ values (1,1,1), (1,2,2), (1,3,3),
+ (2,1,4), (2,2,5), (2,3,6),
+ (2,4,7), (2,5,8);
+insert into t1 select NULL, NULL, c1+10,c2,c3+10 from t1;
+insert into t1 select NULL, NULL, c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+
+create table tmp as select * from t1;
+
+--echo #######################################
+--echo # Test without any index #
+--echo #######################################
+--source include/update_use_source_cases.inc
+
+--echo #######################################
+--echo # Test with an index #
+--echo #######################################
+create index t1_c2 on t1 (c2,c1);
+analyze table t1;
+--source include/update_use_source_cases.inc
+
+--echo #######################################
+--echo # Test with a primary key #
+--echo #######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+analyze table t1;
+--source include/update_use_source_cases.inc
+
+--echo # Update with error "Subquery returns more than 1 row"
+--error ER_SUBQUERY_NO_1_ROW
+update t1 set c2=(select c2 from t1);
+--sorted_result
+select c1,c2,c3 from t1;
+
+--echo # Update with error "Subquery returns more than 1 row"
+--echo # and order by
+--error ER_SUBQUERY_NO_1_ROW
+update t1 set c2=(select c2 from t1) order by c3;
+--sorted_result
+select c1,c2,c3 from t1;
+
+-- echo # Duplicate value on update a primary key
+--error ER_DUP_ENTRY
+
+update t1 set c3=0
+ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+-- echo # Duplicate value on update a primary key with ignore
--enable_info ONCE
-update t1
- set c1=(select a.c3
- from t1 a
- where a.c3 = t1.c3);
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
-rollback;
-
---echo #
---echo # Update with search clause on the same table
---echo #
-
-start transaction;
+update ignore t1 set c3=0
+ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+-- echo # Duplicate value on update a primary key and limit
+--error ER_DUP_ENTRY
+update t1 set c3=0
+ where exists (select 'X' from t1 a where a.c2 = t1.c2)
+ and c2 >= 3 limit 2;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+-- echo # Duplicate value on update a primary key with ignore
+-- echo # and limit
--enable_info ONCE
-update t1
- set c1=10
- where c1 <2
- and exists (select 'X'
- from t1 a
- where a.c1 = t1.c1);
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
-rollback;
-
---echo #
---echo # Update via RANGE or INDEX access if an index or a primary key exists
---echo #
-
-explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
-start transaction;
+update ignore t1 set c3=0
+ where exists (select 'X' from t1 a where a.c2 = t1.c2)
+ and c2 >= 3 limit 2;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo # Update no rows found
--enable_info ONCE
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
-
---echo #
---echo # Update with order by
---echo #
-
-start transaction;
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 order by c2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
-
---echo #
---echo Update using a view in subquery
---echo #
-
-start transaction;
+update t1 set c1=10
+ where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1 + 10);
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo # Update no rows changed
+drop trigger trg_t1;
--enable_info ONCE
-update t1
- set c1=c1 +(select max(a.c2)
- from v1 a
- where a.c1 = t1.c1) ;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
+update t1 set c1=c1
+ where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1);
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
--echo #
---echo # Update throw a view
+--echo # Check call of after trigger
--echo #
-start transaction;
---enable_info ONCE
-update v1
- set c1=c1 + (select max(a.c2)
- from t1 a
- where a.c1 = v1.c1) +10
-where c3 > 3;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
-
---echo #
---echo # Update through a view and using the view in subquery
---echo #
+delimiter /;
+create or replace trigger trg_t2 after update on t1 for each row
+begin
+ declare msg varchar(100);
+ if (new.c3 = 5) then
+ set msg=concat('in after update trigger on ',new.c3);
+ SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
+ end if;
+end;
+/
+delimiter ;/
+--error 1644
-start transaction;
---enable_info ONCE
-update v1
- set c1=c1 + 1
- where c1 <2
- and exists (select 'X'
- from v1 a
- where a.c1 = v1.c1);
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
+update t1 set c1=2
+ where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
--echo #
---echo # Update through a view and using the view in subquery
+--echo # Check update with order by and after trigger
--echo #
-start transaction;
---enable_info ONCE
-update v1
- set c1=(select max(a.c1)+10
- from v1 a
- where a.c1 = v1.c1)
- where c1 <10
- and exists (select 'X'
- from v1 a
- where a.c2 = v1.c2);
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
-rollback;
+--error 1644
+update t1 set c1=2
+ where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1)
+ order by t1.c2, t1.c1;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+drop view v1;
--echo #
---echo # Update of the index or primary key (c3)
+--echo # Check update on view with check option
--echo #
-start transaction;
-explain update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
---enable_info ONCE
-update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
-select c3 from t1;
-rollback;
+create view v1 as select * from t1 where c2=2 with check option;
---echo #
---echo # update with a limit
---echo #
+-- error 1369
+update v1 set c2=3 where c1=1;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
-start transaction;
---enable_info ONCE
-update t1
- set c1=(select a.c3
- from t1 a
- where a.c3 = t1.c3)
- limit 2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
-rollback;
+-- error 1369
+update v1 set c2=(select max(c3) from v1) where c1=1;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
---echo #
---echo # update with a limit and an order by
---echo #
+update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
+--sorted_result
+select c1,c2,c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
-start transaction;
---enable_info ONCE
-update t1
- set c1=(select a.c3
- from t1 a
- where a.c3 = t1.c3)
- order by c3 desc limit 2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
-rollback;
---enable_view_protocol
+drop table tmp;
+drop view v1;
+drop table t1;
diff --git a/mysql-test/include/update_use_source_cases.inc b/mysql-test/include/update_use_source_cases.inc
new file mode 100644
index 00000000000..f1025f75cb1
--- /dev/null
+++ b/mysql-test/include/update_use_source_cases.inc
@@ -0,0 +1,183 @@
+--echo #
+--echo # Update with value from subquery on the same table
+--echo #
+
+analyze table t1 persistent for all;
+let $q = update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+eval explain select * from t1;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with EXISTS subquery over the updated table
+--echo # in WHERE + possibly sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+let $c = c1 <2
+ and exists (select 'X' from t1 a where a.c1 = t1.c1);
+let $q = update t1 set c1=10 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with EXISTS subquery over the updated table
+--echo # in WHERE + non-sargable condition
+--echo #
+
+analyze table t1 persistent for all;
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+let $q = update t1 set c1=c1+10 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with order by
+--echo #
+
+analyze table t1 persistent for all;
+let $c = exists (select 'X' from t1 a where a.c2 = t1.c2)
+ and c2 >= 3 order by c2;
+let $q = update t1 set c1=c1+10 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with a reference to view in subquery
+--echo # in settable value
+--echo #
+
+analyze table t1 persistent for all;
+let $q = update t1 set c1=c1 +(select max(a.c2) from v1 a
+ where a.c1 = t1.c1);
+eval explain select * from t1;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update view
+--echo #
+
+analyze table t1 persistent for all;
+let $q = update v1 set c1=c1 + (select max(a.c2) from t1 a
+ where a.c1 = v1.c1) +10 where c3 > 3;
+eval explain select * from v1;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update view with reference to the same view in subquery
+--echo #
+
+analyze table t1 persistent for all;
+let $c = c1 <2
+ and exists (select 'X' from v1 a where a.c1 = v1.c1);
+let $q = update v1 set c1=c1 + 1 where $c;
+eval explain select * from v1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update view with EXISTS and reference to the same view in subquery
+--echo #
+
+analyze table t1 persistent for all;
+let $c = c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+let $q = update v1
+ set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+ where $c;
+eval explain select * from v1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with IN predicand over the updated table in WHERE
+--echo #
+
+analyze table t1 persistent for all;
+let $c = c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+let $q = update t1 set c3=c3+110 where $c;
+eval explain select * from t1 where $c;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+--sorted_result
+select c3 from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with a limit
+--echo #
+
+analyze table t1 persistent for all;
+let $q = update t1
+ set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+eval explain select * from t1 limit 2;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
+
+--echo #
+--echo # Update with a limit and an order by
+--echo #
+
+analyze table t1 persistent for all;
+let $q=update t1
+ set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+ order by c3 desc limit 2;
+eval explain select * from t1 order by c3 desc limit 2;
+eval explain $q;
+--enable_info ONCE
+eval $q;
+select concat(old_c1,'->',c1),c3,
+ case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+truncate table t1;
+insert into t1 select * from tmp;
diff --git a/mysql-test/include/update_use_source_ext.inc b/mysql-test/include/update_use_source_ext.inc
new file mode 100644
index 00000000000..004f7a96fd5
--- /dev/null
+++ b/mysql-test/include/update_use_source_ext.inc
@@ -0,0 +1,59 @@
+--echo #
+--echo # Test on dynamic columns (blob)
+--echo #
+
+create table assets (
+ item_name varchar(32) primary key, -- A common attribute for all items
+ dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets VALUES ('MariaDB T-shirt',
+ COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets VALUES ('Thinkpad Laptop',
+ COLUMN_CREATE('color', 'black', 'price', 500));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+ FROM assets;
+UPDATE assets
+ SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years')
+ WHERE item_name='Thinkpad Laptop';
+SELECT item_name,
+ COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+ FROM assets;
+UPDATE assets
+ SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
+ WHERE item_name in
+ (select b.item_name from assets b
+ where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name,
+ COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+ FROM assets;
+
+UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty',
+ (select COLUMN_GET(b.dynamic_cols, 'color' as char)
+ from assets b
+ where assets.item_name = item_name));
+SELECT item_name,
+ COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+ FROM assets;
+drop table assets;
+
+--echo #
+--echo # Test on fulltext columns
+--echo #
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+ ('MySQL vs MariaDB database'),
+ ('Oracle vs MariaDB database'),
+ ('PostgreSQL vs MariaDB database'),
+ ('MariaDB overview'),
+ ('Foreign keys'),
+ ('Primary keys'),
+ ('Indexes'),
+ ('Transactions'),
+ ('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+
+update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5)))
+ from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
+ where MATCH(copy) AGAINST('keys');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('mykeyword');
+drop table ft2;
diff --git a/mysql-test/main/analyze_stmt_privileges2.result b/mysql-test/main/analyze_stmt_privileges2.result
index 3f09b1722b6..244fc5a739e 100644
--- a/mysql-test/main/analyze_stmt_privileges2.result
+++ b/mysql-test/main/analyze_stmt_privileges2.result
@@ -3016,6 +3016,7 @@ ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for unde
ANALYZE UPDATE v1 SET a = 10;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
UPDATE v1 SET a = a + 1;
+ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v1'
EXPLAIN UPDATE v1 SET a = a + 1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
ANALYZE UPDATE v1 SET a = a + 1;
@@ -4743,6 +4744,7 @@ ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for unde
ANALYZE UPDATE v2 SET a = 10;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
UPDATE v2 SET a = a + 1;
+ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v2'
EXPLAIN UPDATE v2 SET a = a + 1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
ANALYZE UPDATE v2 SET a = a + 1;
@@ -4841,12 +4843,11 @@ ANALYZE UPDATE v2 SET a = 10;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 43 43.00 100.00 6.98 Using where
UPDATE v2 SET a = a + 1;
+ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v2'
EXPLAIN UPDATE v2 SET a = a + 1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 43 Using where
+ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v2'
ANALYZE UPDATE v2 SET a = a + 1;
-id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 43 43.00 100.00 6.98 Using where
+ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v2'
UPDATE v2, t2 SET v2.a = v2.a + 1 WHERE v2.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 'v2'
EXPLAIN UPDATE v2, t2 SET v2.a = v2.a + 1 WHERE v2.a = t2.a;
diff --git a/mysql-test/main/analyze_stmt_privileges2.test b/mysql-test/main/analyze_stmt_privileges2.test
index a0f1f4908b6..8b011c2b592 100644
--- a/mysql-test/main/analyze_stmt_privileges2.test
+++ b/mysql-test/main/analyze_stmt_privileges2.test
@@ -2987,8 +2987,7 @@ EXPLAIN UPDATE v1 SET a = 10;
--error ER_VIEW_NO_EXPLAIN
ANALYZE UPDATE v1 SET a = 10;
-# Wrong result due to MDEV-7042
-#--error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_COLUMNACCESS_DENIED_ERROR
UPDATE v1 SET a = a + 1;
# Strange error code due to MDEV-7042
#--error ER_COLUMNACCESS_DENIED_ERROR
@@ -4891,8 +4890,7 @@ EXPLAIN UPDATE v2 SET a = 10;
--error ER_VIEW_NO_EXPLAIN
ANALYZE UPDATE v2 SET a = 10;
-# Wrong result due to MDEV-7042
-# --error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_COLUMNACCESS_DENIED_ERROR
UPDATE v2 SET a = a + 1;
# Strange error code due to MDEV-7042
#--error ER_COLUMNACCESS_DENIED_ERROR
@@ -5009,14 +5007,11 @@ UPDATE v2 SET a = 10;
EXPLAIN UPDATE v2 SET a = 10;
ANALYZE UPDATE v2 SET a = 10;
-# Wrong result due to MDEV-7042
-# --error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_COLUMNACCESS_DENIED_ERROR
UPDATE v2 SET a = a + 1;
-# Wrong result due to MDEV-7042
-# --error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_COLUMNACCESS_DENIED_ERROR
EXPLAIN UPDATE v2 SET a = a + 1;
-# Wrong result due to MDEV-7042
-# --error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_COLUMNACCESS_DENIED_ERROR
ANALYZE UPDATE v2 SET a = a + 1;
--error ER_COLUMNACCESS_DENIED_ERROR
diff --git a/mysql-test/main/delete.result b/mysql-test/main/delete.result
index 900c14c5578..c4bf335091a 100644
--- a/mysql-test/main/delete.result
+++ b/mysql-test/main/delete.result
@@ -564,3 +564,50 @@ having t3.a > any (select t2.b from t2
where t2.b*10 < sum(t3.b)));
drop table t1,t2,t3;
End of 10.4 tests
+#
+# MDEV-29428: DELETE with ORDER BY without LIMIT clause
+#
+create table t1 (c1 integer, c2 integer, c3 integer);
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+create temporary table t select * from t1;
+explain delete from t1 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL 8 Deleting all rows
+delete from t1 order by c2;
+select *from t1;
+c1 c2 c3
+delete from t1;
+insert into t1 select * from t;
+explain delete from t1
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
+delete from t1
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+select *from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+2 1 4
+2 2 5
+delete from t1;
+insert into t1 select * from t;
+explain delete from t1
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
+order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
+delete from t1
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
+order by c2;
+select *from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+2 1 4
+2 2 5
+drop table t1;
+End of 11.1 tests
diff --git a/mysql-test/main/delete.test b/mysql-test/main/delete.test
index 733384193e5..a4057666818 100644
--- a/mysql-test/main/delete.test
+++ b/mysql-test/main/delete.test
@@ -624,3 +624,45 @@ update t1 set t1.a=t1.a+10
drop table t1,t2,t3;
--echo End of 10.4 tests
+
+--echo #
+--echo # MDEV-29428: DELETE with ORDER BY without LIMIT clause
+--echo #
+
+create table t1 (c1 integer, c2 integer, c3 integer);
+
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+
+create temporary table t select * from t1;
+
+let $q1=
+delete from t1 order by c2;
+eval explain $q1;
+eval $q1;
+select *from t1;
+
+delete from t1;
+insert into t1 select * from t;
+
+let $q2=
+delete from t1
+ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+eval explain $q2;
+eval $q2;
+select *from t1;
+
+delete from t1;
+insert into t1 select * from t;
+
+let $q3=
+delete from t1
+ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
+ order by c2;
+eval explain $q3;
+eval $q3;
+select *from t1;
+
+drop table t1;
+
+--echo End of 11.1 tests
diff --git a/mysql-test/main/delete_single_to_multi.result b/mysql-test/main/delete_single_to_multi.result
new file mode 100644
index 00000000000..57cc224203a
--- /dev/null
+++ b/mysql-test/main/delete_single_to_multi.result
@@ -0,0 +1,4252 @@
+DROP DATABASE IF EXISTS dbt3_s001;
+CREATE DATABASE dbt3_s001;
+use dbt3_s001;
+create index i_n_name on nation(n_name);
+analyze table
+nation, lineitem, customer, orders, part, supplier, partsupp, region
+persistent for all;
+Table Op Msg_type Msg_text
+dbt3_s001.nation analyze status Engine-independent statistics collected
+dbt3_s001.nation analyze status OK
+dbt3_s001.lineitem analyze status Engine-independent statistics collected
+dbt3_s001.lineitem analyze status OK
+dbt3_s001.customer analyze status Engine-independent statistics collected
+dbt3_s001.customer analyze status OK
+dbt3_s001.orders analyze status Engine-independent statistics collected
+dbt3_s001.orders analyze status OK
+dbt3_s001.part analyze status Engine-independent statistics collected
+dbt3_s001.part analyze status OK
+dbt3_s001.supplier analyze status Engine-independent statistics collected
+dbt3_s001.supplier analyze status OK
+dbt3_s001.partsupp analyze status Engine-independent statistics collected
+dbt3_s001.partsupp analyze status OK
+dbt3_s001.region analyze status Engine-independent statistics collected
+dbt3_s001.region analyze status OK
+# Pullout
+# =======
+explain
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+explain format=json
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.052271677,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_n_name"],
+ "key": "i_n_name",
+ "key_length": "26",
+ "used_key_parts": ["n_name"],
+ "ref": ["const"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.002024411,
+ "filtered": 100,
+ "index_condition": "nation.n_name = 'PERU'"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 1,
+ "rows": 6,
+ "cost": 0.008193756,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 108,
+ "selectivity_pct": 7.2
+ },
+ "loops": 6,
+ "rows": 15,
+ "cost": 0.04205351,
+ "filtered": 7.199999809,
+ "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
+ }
+ }
+ ]
+ }
+}
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+create table t as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+explain
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+explain format=json
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.052271677,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_n_name"],
+ "key": "i_n_name",
+ "key_length": "26",
+ "used_key_parts": ["n_name"],
+ "ref": ["const"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.002024411,
+ "filtered": 100,
+ "index_condition": "nation.n_name = 'PERU'"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 1,
+ "rows": 6,
+ "cost": 0.008193756,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 108,
+ "selectivity_pct": 7.2
+ },
+ "loops": 6,
+ "rows": 15,
+ "cost": 0.04205351,
+ "filtered": 7.199999809,
+ "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
+ }
+ }
+ ]
+ }
+}
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+insert into orders select * from t;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+drop table t;
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+create table t as
+select * from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+explain
+delete from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+delete from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+insert into partsupp select * from t;
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+drop table t;
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+create table t as
+select * from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+explain
+delete from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+delete from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+insert into partsupp select * from t;
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+drop table t;
+explain
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+2500 2 0.02
+2500 4 0.02
+4996 1 0.01
+933 1 0.04
+create table t as
+select * from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+explain
+delete from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
+delete from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+insert into lineitem select * from t;
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+2500 2 0.02
+2500 4 0.02
+4996 1 0.01
+933 1 0.04
+drop table t;
+# FirstMatch
+# ==========
+set optimizer_switch='materialization=off';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25 Using where
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (9%) Using where; FirstMatch(customer); Using rowid filter
+explain format=json
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.40015207,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY", "i_n_regionkey"],
+ "loops": 1,
+ "rows": 25,
+ "cost": 0.013945725,
+ "filtered": 40,
+ "attached_condition": "nation.n_regionkey in (1,2)"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 10,
+ "rows": 6,
+ "cost": 0.08009436,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 140,
+ "selectivity_pct": 9.333333333
+ },
+ "loops": 60,
+ "rows": 15,
+ "cost": 0.306111985,
+ "filtered": 6.666666508,
+ "attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
+ "first_match": "customer"
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table t as
+select * from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+explain
+delete from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25 Using where
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (9%) Using where; FirstMatch(customer); Using rowid filter
+explain format=json
+delete from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.40015207,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY", "i_n_regionkey"],
+ "loops": 1,
+ "rows": 25,
+ "cost": 0.013945725,
+ "filtered": 40,
+ "attached_condition": "nation.n_regionkey in (1,2)"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 10,
+ "rows": 6,
+ "cost": 0.08009436,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 140,
+ "selectivity_pct": 9.333333333
+ },
+ "loops": 60,
+ "rows": 15,
+ "cost": 0.306111985,
+ "filtered": 6.666666508,
+ "attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
+ "first_match": "customer"
+ }
+ }
+ ]
+ }
+}
+delete from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+drop table t;
+set optimizer_switch='materialization=default';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; FirstMatch(customer); Using rowid filter
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+create table t as
+select * from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+explain
+delete from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; FirstMatch(customer); Using rowid filter
+delete from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+drop table t;
+# Materialization
+# ===============
+set optimizer_switch='firstmatch=off';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
+3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000014 5266.3
+Customer#000000025 7133.7
+Customer#000000035 1228.24
+Customer#000000038 6345.11
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000113 2912
+Customer#000000121 6428.32
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table t as
+select * from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+explain
+delete from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
+3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+delete from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000014 5266.3
+Customer#000000025 7133.7
+Customer#000000035 1228.24
+Customer#000000038 6345.11
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000113 2912
+Customer#000000121 6428.32
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+drop table t;
+set optimizer_switch='firstmatch=default';
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+explain format=json
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.382051418,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY"],
+ "loops": 1,
+ "rows": 150,
+ "cost": 0.03493875,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ALL",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "loops": 1,
+ "rows": 1500,
+ "cost": 0.2532975,
+ "filtered": 16.13333321,
+ "attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+explain format=json
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.37364371,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY"],
+ "loops": 1,
+ "rows": 150,
+ "cost": 0.026531042,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ALL",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "loops": 1,
+ "rows": 1500,
+ "cost": 0.2532975,
+ "filtered": 16.13333321,
+ "attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+drop table t;
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 114 Using index condition; Using where
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000034 8589.7
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 114 Using index condition; Using where
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000034 8589.7
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+drop table t;
+# Materialization SJM
+# ===================
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 28
+1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 <subquery2>.o_custkey 1
+2 MATERIALIZED orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
+explain format=json
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.085533248,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "ALL",
+ "possible_keys": ["distinct_key"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.03691572,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "cost": 0.053826401,
+ "having_condition": "count(orders.o_custkey) > 1",
+ "temporary_table": {
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["i_o_orderdate"],
+ "key": "i_o_orderdate",
+ "key_length": "4",
+ "used_key_parts": ["o_orderDATE"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.035889016,
+ "filtered": 100,
+ "index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["c_custkey"],
+ "ref": ["<subquery2>.o_custkey"],
+ "loops": 28,
+ "rows": 1,
+ "cost": 0.048617528,
+ "filtered": 100
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 28
+1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 <subquery2>.o_custkey 1
+2 MATERIALIZED orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
+explain format=json
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.054856476,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "ALL",
+ "possible_keys": ["distinct_key"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.03691572,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "cost": 0.053826401,
+ "having_condition": "count(orders.o_custkey) > 1",
+ "temporary_table": {
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["i_o_orderdate"],
+ "key": "i_o_orderdate",
+ "key_length": "4",
+ "used_key_parts": ["o_orderDATE"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.035889016,
+ "filtered": 100,
+ "index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["c_custkey"],
+ "ref": ["<subquery2>.o_custkey"],
+ "loops": 28,
+ "rows": 1,
+ "cost": 0.017940756,
+ "filtered": 100
+ }
+ }
+ ]
+ }
+}
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+drop table t;
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
+2 MATERIALIZED orders ALL i_o_orderdate NULL NULL NULL 1500 Using where; Using temporary
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000016 4681.03
+Customer#000000037 -917.75
+Customer#000000046 5744.59
+Customer#000000091 4643.14
+Customer#000000103 2757.45
+Customer#000000118 3582.37
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
+2 MATERIALIZED orders ALL i_o_orderdate NULL NULL NULL 1500 Using where; Using temporary
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000016 4681.03
+Customer#000000037 -917.75
+Customer#000000046 5744.59
+Customer#000000091 4643.14
+Customer#000000103 2757.45
+Customer#000000118 3582.37
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+drop table t;
+# Pullout PS
+# ==========
+prepare stmt from "
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+";
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+create table t as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+execute stmt;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+insert into orders select * from t;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+create table r as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+execute stmt;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+insert into orders select * from r;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+drop table t,r;
+deallocate prepare stmt;
+# FirstMatch PS
+# =============
+set optimizer_switch='materialization=off';
+prepare stmt from "
+delete from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+";
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table t as
+select * from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+execute stmt;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table r as
+select * from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+execute stmt;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+drop table t,r;
+deallocate prepare stmt;
+set optimizer_switch='materialization=default';
+# Materialization PS
+# ==================
+prepare stmt from "
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08') and c_name like ?;
+";
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+set @a1='Customer#%1_';
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08') and c_name like @a1;
+execute stmt using @a1;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+set @a2='Customer#%3_';
+create table r as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08') and c_name like @a2;
+execute stmt using @a2;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+drop table t,r;
+deallocate prepare stmt;
+# Materialization SJM PS
+# ======================
+prepare stmt from "
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1) and c_acctbal between ? and ?;
+";
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+set @a1=3500;
+set @a2=4000;
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1) and c_acctbal between @a1 and @a2;
+execute stmt using @a1, @a2;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+set @a3=-1000;
+set @a4=3500;
+create table r as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1) and c_acctbal between @a3 and @a4;
+execute stmt using @a3, @a4;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+drop table t,r;
+deallocate prepare stmt;
+# Pullout SP
+# ==========
+create procedure p(a1 int, a2 int)
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU')) and o_totalprice between a1 and a2;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+create table t as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU')) and o_totalprice between 150000 and 200000;
+call p(150000, 200000);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5382 138423.03
+644 201268.06
+737 12984.85
+insert into orders select * from t;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+create table r as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU')) and o_totalprice between 180000 and 210000;
+call p(180000, 210000);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5121 150334.57
+5382 138423.03
+737 12984.85
+insert into orders select * from r;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+1729 12137.76
+2880 145761.99
+3142 16030.15
+5095 184583.99
+5121 150334.57
+5382 138423.03
+644 201268.06
+737 12984.85
+drop table t,r;
+drop procedure p;
+# FirstMatch SP
+# =============
+set optimizer_switch='materialization=off';
+create procedure p(a int)
+delete from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08') and c_acctbal > a;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table t as
+select * from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08') and c_acctbal > 4000;
+call p(4000);
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000017 6.34
+Customer#000000022 591.98
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000077 1738.87
+Customer#000000092 1182.91
+Customer#000000097 2164.48
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000124 1842.49
+Customer#000000133 2314.67
+Customer#000000142 2209.81
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+create table r as
+select * from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08') and c_acctbal > 2000;
+call p(2000);
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000017 6.34
+Customer#000000022 591.98
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000077 1738.87
+Customer#000000092 1182.91
+Customer#000000124 1842.49
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000047 274.58
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000077 1738.87
+Customer#000000082 9468.34
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000097 2164.48
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000106 3288.42
+Customer#000000115 7508.92
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000133 2314.67
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+drop table t,r;
+drop procedure p;
+set optimizer_switch='materialization=default';
+# Materialization SP
+# ==================
+create procedure p()
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+call p();
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+create table r as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+call p();
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+drop table t,r;
+drop procedure p;
+# Materialization SJM SP
+# ======================
+create procedure p()
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+call p();
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+insert into customer select * from t;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+create table r as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+call p();
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+insert into customer select * from r;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000056 6530.86
+Customer#000000118 3582.37
+drop table t,r;
+drop procedure p;
+# Checking limitations
+# ====================
+# Check for DELETE ... RETURNING with SJ subquery in WHERE
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name
+Customer#000000001
+Customer#000000002
+Customer#000000005
+Customer#000000007
+Customer#000000008
+Customer#000000010
+Customer#000000011
+Customer#000000013
+Customer#000000014
+Customer#000000016
+Customer#000000017
+Customer#000000019
+Customer#000000022
+Customer#000000023
+Customer#000000025
+Customer#000000028
+Customer#000000029
+Customer#000000031
+Customer#000000032
+Customer#000000034
+Customer#000000035
+Customer#000000037
+Customer#000000038
+Customer#000000040
+Customer#000000041
+Customer#000000043
+Customer#000000044
+Customer#000000046
+Customer#000000047
+Customer#000000049
+Customer#000000052
+Customer#000000053
+Customer#000000055
+Customer#000000056
+Customer#000000058
+Customer#000000059
+Customer#000000061
+Customer#000000062
+Customer#000000064
+Customer#000000065
+Customer#000000067
+Customer#000000070
+Customer#000000071
+Customer#000000073
+Customer#000000074
+Customer#000000076
+Customer#000000079
+Customer#000000080
+Customer#000000082
+Customer#000000083
+Customer#000000085
+Customer#000000086
+Customer#000000088
+Customer#000000089
+Customer#000000091
+Customer#000000092
+Customer#000000094
+Customer#000000095
+Customer#000000097
+Customer#000000098
+Customer#000000100
+Customer#000000101
+Customer#000000103
+Customer#000000104
+Customer#000000106
+Customer#000000107
+Customer#000000109
+Customer#000000110
+Customer#000000112
+Customer#000000115
+Customer#000000116
+Customer#000000118
+Customer#000000121
+Customer#000000122
+Customer#000000127
+Customer#000000128
+Customer#000000130
+Customer#000000131
+Customer#000000133
+Customer#000000134
+Customer#000000136
+Customer#000000137
+Customer#000000139
+Customer#000000140
+Customer#000000142
+Customer#000000143
+Customer#000000145
+Customer#000000148
+Customer#000000149
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08') returning c_name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL NULL NULL NULL NULL 150 Using where
+2 DEPENDENT SUBQUERY orders index_subquery i_o_orderdate,i_o_custkey i_o_custkey 5 func 15 Using where
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08') returning c_name;
+c_name
+Customer#000000001
+Customer#000000002
+Customer#000000005
+Customer#000000007
+Customer#000000008
+Customer#000000010
+Customer#000000011
+Customer#000000013
+Customer#000000014
+Customer#000000016
+Customer#000000017
+Customer#000000019
+Customer#000000022
+Customer#000000023
+Customer#000000025
+Customer#000000028
+Customer#000000029
+Customer#000000031
+Customer#000000032
+Customer#000000034
+Customer#000000035
+Customer#000000037
+Customer#000000038
+Customer#000000040
+Customer#000000041
+Customer#000000043
+Customer#000000044
+Customer#000000046
+Customer#000000047
+Customer#000000049
+Customer#000000052
+Customer#000000053
+Customer#000000055
+Customer#000000056
+Customer#000000058
+Customer#000000059
+Customer#000000061
+Customer#000000062
+Customer#000000064
+Customer#000000065
+Customer#000000067
+Customer#000000070
+Customer#000000071
+Customer#000000073
+Customer#000000074
+Customer#000000076
+Customer#000000079
+Customer#000000080
+Customer#000000082
+Customer#000000083
+Customer#000000085
+Customer#000000086
+Customer#000000088
+Customer#000000089
+Customer#000000091
+Customer#000000092
+Customer#000000094
+Customer#000000095
+Customer#000000097
+Customer#000000098
+Customer#000000100
+Customer#000000101
+Customer#000000103
+Customer#000000104
+Customer#000000106
+Customer#000000107
+Customer#000000109
+Customer#000000110
+Customer#000000112
+Customer#000000115
+Customer#000000116
+Customer#000000118
+Customer#000000121
+Customer#000000122
+Customer#000000127
+Customer#000000128
+Customer#000000130
+Customer#000000131
+Customer#000000133
+Customer#000000134
+Customer#000000136
+Customer#000000137
+Customer#000000139
+Customer#000000140
+Customer#000000142
+Customer#000000143
+Customer#000000145
+Customer#000000148
+Customer#000000149
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name
+insert into customer select * from t;
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name
+Customer#000000001
+Customer#000000002
+Customer#000000005
+Customer#000000007
+Customer#000000008
+Customer#000000010
+Customer#000000011
+Customer#000000013
+Customer#000000014
+Customer#000000016
+Customer#000000017
+Customer#000000019
+Customer#000000022
+Customer#000000023
+Customer#000000025
+Customer#000000028
+Customer#000000029
+Customer#000000031
+Customer#000000032
+Customer#000000034
+Customer#000000035
+Customer#000000037
+Customer#000000038
+Customer#000000040
+Customer#000000041
+Customer#000000043
+Customer#000000044
+Customer#000000046
+Customer#000000047
+Customer#000000049
+Customer#000000052
+Customer#000000053
+Customer#000000055
+Customer#000000056
+Customer#000000058
+Customer#000000059
+Customer#000000061
+Customer#000000062
+Customer#000000064
+Customer#000000065
+Customer#000000067
+Customer#000000070
+Customer#000000071
+Customer#000000073
+Customer#000000074
+Customer#000000076
+Customer#000000079
+Customer#000000080
+Customer#000000082
+Customer#000000083
+Customer#000000085
+Customer#000000086
+Customer#000000088
+Customer#000000089
+Customer#000000091
+Customer#000000092
+Customer#000000094
+Customer#000000095
+Customer#000000097
+Customer#000000098
+Customer#000000100
+Customer#000000101
+Customer#000000103
+Customer#000000104
+Customer#000000106
+Customer#000000107
+Customer#000000109
+Customer#000000110
+Customer#000000112
+Customer#000000115
+Customer#000000116
+Customer#000000118
+Customer#000000121
+Customer#000000122
+Customer#000000127
+Customer#000000128
+Customer#000000130
+Customer#000000131
+Customer#000000133
+Customer#000000134
+Customer#000000136
+Customer#000000137
+Customer#000000139
+Customer#000000140
+Customer#000000142
+Customer#000000143
+Customer#000000145
+Customer#000000148
+Customer#000000149
+drop table t;
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name
+Customer#000000013
+Customer#000000032
+Customer#000000037
+Customer#000000056
+Customer#000000118
+create table t as
+select * from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+explain
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1) returning c_name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL NULL NULL NULL NULL 150 Using where
+2 DEPENDENT SUBQUERY orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
+delete from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1) returning c_name;
+c_name
+Customer#000000013
+Customer#000000032
+Customer#000000037
+Customer#000000056
+Customer#000000118
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name
+insert into customer select * from t;
+select c_name from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name
+Customer#000000013
+Customer#000000032
+Customer#000000037
+Customer#000000056
+Customer#000000118
+drop table t;
+# Check for DELETE ... ORDER BY ...LIMIT with SJ subquery in WHERE
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+1344 43809.37
+1856 189361.42
+1925 146382.71
+3139 40975.96
+324 26868.85
+4903 34363.63
+5607 24660.06
+# Should not use semi-join conversion because has ORDER BY ... LIMIT
+explain
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2))
+order by o_totalprice limit 500;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY orders range i_o_orderdate i_o_orderdate 4 NULL 108 Using where; Using filesort
+2 DEPENDENT SUBQUERY customer unique_subquery PRIMARY,i_c_nationkey PRIMARY 4 func 1 Using where
+create table t as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+select o_orderkey, o_totalprice from t;
+o_orderkey o_totalprice
+1221 117397.16
+324 26868.85
+1856 189361.42
+4903 34363.63
+5607 24660.06
+1344 43809.37
+1925 146382.71
+3139 40975.96
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2))
+order by o_totalprice limit 500;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+insert into orders select * from t;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+1344 43809.37
+1856 189361.42
+1925 146382.71
+3139 40975.96
+324 26868.85
+4903 34363.63
+5607 24660.06
+drop table t;
+# Should use semi-join converion
+explain
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer range PRIMARY,i_c_nationkey i_c_nationkey 5 NULL 13 Using index condition
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+create table t as
+select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+select o_orderkey, o_totalprice from t;
+o_orderkey o_totalprice
+1221 117397.16
+324 26868.85
+1856 189361.42
+4903 34363.63
+5607 24660.06
+1344 43809.37
+1925 146382.71
+3139 40975.96
+delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+insert into orders select * from t;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+1344 43809.37
+1856 189361.42
+1925 146382.71
+3139 40975.96
+324 26868.85
+4903 34363.63
+5607 24660.06
+drop table t;
+CREATE TABLE partsupp_small (
+ps_partkey int(11) NOT NULL DEFAULT '0',
+ps_suppkey int(11) NOT NULL DEFAULT '0',
+ps_availqty int(11) DEFAULT NULL,
+ps_supplycost double DEFAULT NULL,
+ps_comment varchar(199) DEFAULT NULL,
+PRIMARY KEY (ps_partkey,ps_suppkey),
+KEY i_ps_partkey (ps_partkey),
+KEY i_ps_suppkey (ps_suppkey)
+);
+create index i_ps_sup_part on partsupp_small(ps_suppkey, ps_partkey);
+insert into partsupp_small select * from partsupp where ps_partkey <50;
+analyze table partsupp_small persistent for all;
+Table Op Msg_type Msg_text
+dbt3_s001.partsupp_small analyze status Engine-independent statistics collected
+dbt3_s001.partsupp_small analyze status OK
+# LooseScan
+# =========
+explain
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY partsupp_small index PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part PRIMARY 8 NULL 176 Using where; Using index; LooseScan
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index
+explain format=json
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.222764041,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "index",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "PRIMARY",
+ "key_length": "8",
+ "used_key_parts": ["ps_partkey", "ps_suppkey"],
+ "loops": 1,
+ "rows": 176,
+ "cost": 0.019403477,
+ "filtered": 23.86363602,
+ "attached_condition": "partsupp_small.ps_suppkey in (1,2,3)",
+ "using_index": true,
+ "loose_scan": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 42,
+ "rows": 30,
+ "cost": 0.203360564,
+ "filtered": 2.380952358,
+ "using_index": true
+ }
+ }
+ ]
+ }
+}
+explain
+select l_partkey from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY partsupp_small index PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part PRIMARY 8 NULL 176 Using where; Using index; LooseScan
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index
+explain format=json
+select l_partkey from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.222764041,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "index",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "PRIMARY",
+ "key_length": "8",
+ "used_key_parts": ["ps_partkey", "ps_suppkey"],
+ "loops": 1,
+ "rows": 176,
+ "cost": 0.019403477,
+ "filtered": 23.86363602,
+ "attached_condition": "partsupp_small.ps_suppkey in (1,2,3)",
+ "using_index": true,
+ "loose_scan": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 42,
+ "rows": 30,
+ "cost": 0.203360564,
+ "filtered": 2.380952358,
+ "using_index": true
+ }
+ }
+ ]
+ }
+}
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+create table t as
+select * from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+explain
+delete from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY partsupp_small index PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part PRIMARY 8 NULL 176 Using where; Using index; LooseScan
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30
+explain format=json
+delete from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.222764041,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "index",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "PRIMARY",
+ "key_length": "8",
+ "used_key_parts": ["ps_partkey", "ps_suppkey"],
+ "loops": 1,
+ "rows": 176,
+ "cost": 0.019403477,
+ "filtered": 23.86363602,
+ "attached_condition": "partsupp_small.ps_suppkey in (1,2,3)",
+ "using_index": true,
+ "loose_scan": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 42,
+ "rows": 30,
+ "cost": 0.203360564,
+ "filtered": 2.380952358
+ }
+ }
+ ]
+ }
+}
+delete from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+drop table t;
+# LooseScan PS
+# ============
+prepare stmt from "
+delete from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+";
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+create table t as
+select * from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+execute stmt;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+create table r as
+select * from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+execute stmt;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+0
+insert into lineitem select * from r;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+drop tables r, t;
+deallocate prepare stmt;
+# LooseScan SP
+# ============
+create procedure p()
+delete from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+create table t as
+select * from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+call p();
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+create table r as
+select * from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+call p();
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+0
+insert into lineitem select * from r;
+select count(*) from lineitem where l_partkey in
+(select ps_partkey from partsupp_small
+where ps_suppkey in (1,2,3));
+count(*)
+1175
+drop tables r, t;
+drop procedure p;
+# DuplicateWeedout
+# ================
+set @tmp_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='materialization=off';
+analyze table lineitem;
+Table Op Msg_type Msg_text
+dbt3_s001.lineitem analyze status Engine-independent statistics collected
+dbt3_s001.lineitem analyze status OK
+analyze table orders;
+Table Op Msg_type Msg_text
+dbt3_s001.orders analyze status Engine-independent statistics collected
+dbt3_s001.orders analyze status OK
+explain
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY supplier range PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Start temporary
+1 PRIMARY partsupp_small ref PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 4 dbt3_s001.supplier.s_suppkey 17 Using where; Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index; End temporary
+explain format=json
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 4.129940741,
+ "nested_loop": [
+ {
+ "duplicates_removal": [
+ {
+ "table": {
+ "table_name": "supplier",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["s_suppkey"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.001478954,
+ "filtered": 100,
+ "attached_condition": "supplier.s_suppkey < 2",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["dbt3_s001.supplier.s_suppkey"],
+ "loops": 1,
+ "rows": 17,
+ "cost": 0.003160332,
+ "filtered": 79.54545593,
+ "attached_condition": "partsupp_small.ps_partkey is not null",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_suppkey_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 14,
+ "rows": 30,
+ "cost": 0.069152188,
+ "filtered": 100,
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 420.35,
+ "rows": 30,
+ "cost": 1.994712365,
+ "filtered": 0.237896994,
+ "using_index": true
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+explain
+select l_partkey from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY supplier range PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Start temporary
+1 PRIMARY partsupp_small ref PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 4 dbt3_s001.supplier.s_suppkey 17 Using where; Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index; End temporary
+explain format=json
+select l_partkey from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 4.129940741,
+ "nested_loop": [
+ {
+ "duplicates_removal": [
+ {
+ "table": {
+ "table_name": "supplier",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["s_suppkey"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.001478954,
+ "filtered": 100,
+ "attached_condition": "supplier.s_suppkey < 2",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["dbt3_s001.supplier.s_suppkey"],
+ "loops": 1,
+ "rows": 17,
+ "cost": 0.003160332,
+ "filtered": 79.54545593,
+ "attached_condition": "partsupp_small.ps_partkey is not null",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_suppkey_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 14,
+ "rows": 30,
+ "cost": 0.069152188,
+ "filtered": 100,
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 420.35,
+ "rows": 30,
+ "cost": 1.994712365,
+ "filtered": 0.237896994,
+ "using_index": true
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+create table t as
+select * from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+explain
+delete from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY supplier range PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Start temporary
+1 PRIMARY partsupp_small ref PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 4 dbt3_s001.supplier.s_suppkey 17 Using where; Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index; End temporary
+explain format=json
+delete from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 4.129940741,
+ "nested_loop": [
+ {
+ "duplicates_removal": [
+ {
+ "table": {
+ "table_name": "supplier",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["s_suppkey"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.001478954,
+ "filtered": 100,
+ "attached_condition": "supplier.s_suppkey < 2",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["dbt3_s001.supplier.s_suppkey"],
+ "loops": 1,
+ "rows": 17,
+ "cost": 0.003160332,
+ "filtered": 79.54545593,
+ "attached_condition": "partsupp_small.ps_partkey is not null",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_suppkey_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 14,
+ "rows": 30,
+ "cost": 0.069152188,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 420.35,
+ "rows": 30,
+ "cost": 1.994712365,
+ "filtered": 0.237896994,
+ "using_index": true
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+delete from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+drop table t;
+# DuplicateWeedout PS
+# ===================
+prepare stmt from "
+delete from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+";
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+create table t as
+select * from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+execute stmt;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+create table r as
+select * from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+execute stmt;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+0
+insert into lineitem select * from r;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+drop tables r, t;
+deallocate prepare stmt;
+# DuplicateWeedout SP
+# ===================
+create procedure p()
+delete from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+create table t as
+select * from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+call p();
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+0
+insert into lineitem select * from t;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+create table r as
+select * from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+call p();
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+0
+insert into lineitem select * from r;
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+drop tables r, t;
+drop procedure p;
+set @@optimizer_switch=@tmp_optimizer_switch;
+drop table partsupp_small;
+DROP DATABASE dbt3_s001;
diff --git a/mysql-test/main/delete_single_to_multi.test b/mysql-test/main/delete_single_to_multi.test
new file mode 100644
index 00000000000..31f1d157096
--- /dev/null
+++ b/mysql-test/main/delete_single_to_multi.test
@@ -0,0 +1,1069 @@
+--disable_warnings
+DROP DATABASE IF EXISTS dbt3_s001;
+--enable_warnings
+
+CREATE DATABASE dbt3_s001;
+
+use dbt3_s001;
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+--source include/dbt3_s001.inc
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+create index i_n_name on nation(n_name);
+analyze table
+ nation, lineitem, customer, orders, part, supplier, partsupp, region
+persistent for all;
+
+
+--echo # Pullout
+--echo # =======
+
+let $c1=
+ o_orderDATE between '1992-01-01' and '1992-06-30' and
+ o_custkey in (select c_custkey from customer
+ where c_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+explain format=json
+select o_orderkey, o_totalprice from orders where $c1;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+create table t as
+select * from orders where $c1;
+
+eval
+explain
+delete from orders where $c1;
+eval
+explain format=json
+delete from orders where $c1;
+eval
+delete from orders where $c1;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+
+insert into orders select * from t;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+drop table t;
+
+
+let $c2=
+ (ps_partkey, ps_suppkey) in
+ (select p_partkey, s_suppkey from part, supplier
+ where p_retailprice between 901 and 910 and
+ s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+--sorted_result
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+eval
+create table t as
+select * from partsupp where $c2;
+
+eval
+explain
+delete from partsupp where $c2;
+eval
+delete from partsupp where $c2;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+
+insert into partsupp select * from t;
+--sorted_result
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+drop table t;
+
+
+let $c3=
+ ps_partkey in (select p_partkey from part
+ where p_retailprice between 901 and 910) and
+ ps_suppkey in (select s_suppkey from supplier
+ where s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+eval
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+--sorted_result
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+eval
+create table t as
+select * from partsupp where $c3;
+
+eval
+explain
+delete from partsupp where $c3;
+eval
+delete from partsupp where $c3;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+
+insert into partsupp select * from t;
+--sorted_result
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+drop table t;
+
+
+let $c4=
+ l_orderkey in (select o_orderkey from orders
+ where o_custkey in
+ (select c_custkey from customer
+ where c_nationkey in
+ (select n_nationkey from nation
+ where n_name='PERU'))
+ and
+ o_orderDATE between '1992-06-30' and '1992-12-31')
+ and
+ (l_partkey, l_suppkey) in
+ (select p_partkey, s_suppkey from part, supplier
+ where p_retailprice between 901 and 1000 and
+ s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+--sorted_result
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+eval
+create table t as
+select * from lineitem where $c4;
+
+eval
+explain
+delete from lineitem where $c4;
+eval
+delete from lineitem where $c4;
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+
+insert into lineitem select * from t;
+--sorted_result
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+drop table t;
+
+
+--echo # FirstMatch
+--echo # ==========
+
+set optimizer_switch='materialization=off';
+
+let $c5=
+ c_nationkey in (select n_nationkey from nation
+ where n_regionkey in (1,2))
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-10-09' and '1993-06-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c5;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c5;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+eval
+create table t as
+select * from customer where $c5;
+
+eval
+explain
+delete from customer where $c5;
+eval
+explain format=json
+delete from customer where $c5;
+eval
+delete from customer where $c5;
+eval
+select c_name, c_acctbal from customer where $c5;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+drop table t;
+
+set optimizer_switch='materialization=default';
+
+
+let $c6=
+ c_nationkey in (select n_nationkey from nation where n_name='PERU')
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between "1992-01-09" and "1993-01-08");
+
+eval
+explain
+select c_name, c_acctbal from customer where $c6;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c6;
+eval
+create table t as
+select * from customer where $c6;
+
+eval
+explain
+delete from customer where $c6;
+eval
+delete from customer where $c6;
+eval
+select c_name, c_acctbal from customer where $c6;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c6;
+drop table t;
+
+
+--echo # Materialization
+--echo # ===============
+
+set optimizer_switch='firstmatch=off';
+
+let $c7=
+ c_nationkey in (select n_nationkey from nation where
+ n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between "1992-01-09" and "1995-01-08");
+
+eval
+explain
+select c_name, c_acctbal from customer where $c7;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c7;
+eval
+create table t as
+select * from customer where $c7;
+
+eval
+explain
+delete from customer where $c7;
+eval
+delete from customer where $c7;
+eval
+select c_name, c_acctbal from customer where $c7;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c7;
+drop table t;
+
+set optimizer_switch='firstmatch=default';
+
+let $c8=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1993-03-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c8;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c8;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+eval
+create table t as
+select * from customer where $c8;
+
+eval
+explain
+delete from customer where $c8;
+eval
+explain format=json
+delete from customer where $c8;
+eval
+delete from customer where $c8;
+eval
+select c_name, c_acctbal from customer where $c8;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+drop table t;
+
+
+let $c9=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-06-09' and '1993-01-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c9;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c9;
+eval
+create table t as
+select * from customer where $c9;
+
+eval
+explain
+delete from customer where $c9;
+eval
+delete from customer where $c9;
+eval
+select c_name, c_acctbal from customer where $c9;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c9;
+drop table t;
+
+
+--echo # Materialization SJM
+--echo # ===================
+
+let $c10=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+
+eval
+explain
+select c_name, c_acctbal from customer where $c10;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c10;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+eval
+create table t as
+select * from customer where $c10;
+
+eval
+explain
+delete from customer where $c10;
+eval
+explain format=json
+delete from customer where $c10;
+eval
+delete from customer where $c10;
+eval
+select c_name, c_acctbal from customer where $c10;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+drop table t;
+
+
+let $c11=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+
+eval
+explain
+select c_name, c_acctbal from customer where $c11;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c11;
+eval
+create table t as
+select * from customer where $c11;
+
+eval
+explain
+delete from customer where $c11;
+eval
+delete from customer where $c11;
+eval
+select c_name, c_acctbal from customer where $c11;
+
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c11;
+drop table t;
+
+
+--echo # Pullout PS
+--echo # ==========
+
+eval
+prepare stmt from "
+delete from orders where $c1;
+";
+
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+create table t as
+select * from orders where $c1;
+execute stmt;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+insert into orders select * from t;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+create table r as
+select * from orders where $c1;
+execute stmt;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+insert into orders select * from r;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+drop table t,r;
+
+deallocate prepare stmt;
+
+
+--echo # FirstMatch PS
+--echo # =============
+
+set optimizer_switch='materialization=off';
+
+eval
+prepare stmt from "
+delete from customer where $c5;
+";
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+eval
+create table t as
+select * from customer where $c5;
+execute stmt;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+eval
+create table r as
+select * from customer where $c5;
+execute stmt;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+drop table t,r;
+
+deallocate prepare stmt;
+
+set optimizer_switch='materialization=default';
+
+--echo # Materialization PS
+--echo # ==================
+
+eval
+prepare stmt from "
+delete from customer where $c8 and c_name like ?;
+";
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+set @a1='Customer#%1_';
+eval
+create table t as
+select * from customer where $c8 and c_name like @a1;
+execute stmt using @a1;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+set @a2='Customer#%3_';
+eval
+create table r as
+select * from customer where $c8 and c_name like @a2;
+execute stmt using @a2;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+drop table t,r;
+
+deallocate prepare stmt;
+
+
+--echo # Materialization SJM PS
+--echo # ======================
+
+eval
+prepare stmt from "
+delete from customer where $c10 and c_acctbal between ? and ?;
+";
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+set @a1=3500;
+set @a2=4000;
+eval
+create table t as
+select * from customer where $c10 and c_acctbal between @a1 and @a2;
+execute stmt using @a1, @a2;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+set @a3=-1000;
+set @a4=3500;
+eval
+create table r as
+select * from customer where $c10 and c_acctbal between @a3 and @a4;
+execute stmt using @a3, @a4;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+drop table t,r;
+
+deallocate prepare stmt;
+
+
+--echo # Pullout SP
+--echo # ==========
+
+eval
+create procedure p(a1 int, a2 int)
+delete from orders where $c1 and o_totalprice between a1 and a2;
+
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+create table t as
+select * from orders where $c1 and o_totalprice between 150000 and 200000;
+call p(150000, 200000);
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+insert into orders select * from t;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+create table r as
+select * from orders where $c1 and o_totalprice between 180000 and 210000;
+call p(180000, 210000);
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+insert into orders select * from r;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+drop table t,r;
+
+drop procedure p;
+
+
+--echo # FirstMatch SP
+--echo # =============
+
+set optimizer_switch='materialization=off';
+
+eval
+create procedure p(a int)
+delete from customer where $c5 and c_acctbal > a;
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+eval
+create table t as
+select * from customer where $c5 and c_acctbal > 4000;
+call p(4000);
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+eval
+create table r as
+select * from customer where $c5 and c_acctbal > 2000;
+call p(2000);
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c5;
+drop table t,r;
+
+drop procedure p;
+
+set optimizer_switch='materialization=default';
+
+
+--echo # Materialization SP
+--echo # ==================
+
+eval
+create procedure p()
+delete from customer where $c8;
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+eval
+create table t as
+select * from customer where $c8;
+call p();
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+eval
+create table r as
+select * from customer where $c8;
+call p();
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c8;
+drop table t,r;
+
+drop procedure p;
+
+
+--echo # Materialization SJM SP
+--echo # ======================
+
+eval
+create procedure p()
+delete from customer where $c10;
+
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+eval
+create table t as
+select * from customer where $c10;
+call p();
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+eval
+create table r as
+select * from customer where $c10;
+call p();
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+insert into customer select * from r;
+--sorted_result
+eval
+select c_name, c_acctbal from customer where $c10;
+drop table t,r;
+
+drop procedure p;
+
+--echo # Checking limitations
+--echo # ====================
+
+--echo # Check for DELETE ... RETURNING with SJ subquery in WHERE
+
+--sorted_result
+eval
+select c_name from customer where $c8;
+eval
+create table t as
+select * from customer where $c8;
+eval
+explain
+delete from customer where $c8 returning c_name;
+--sorted_result
+eval
+delete from customer where $c8 returning c_name;
+--sorted_result
+eval
+select c_name from customer where $c8;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name from customer where $c8;
+drop table t;
+
+--sorted_result
+eval
+select c_name from customer where $c10;
+eval
+create table t as
+select * from customer where $c10;
+eval
+explain
+delete from customer where $c10 returning c_name;
+--sorted_result
+eval
+delete from customer where $c10 returning c_name;
+--sorted_result
+eval
+select c_name from customer where $c10;
+insert into customer select * from t;
+--sorted_result
+eval
+select c_name from customer where $c10;
+drop table t;
+
+--echo # Check for DELETE ... ORDER BY ...LIMIT with SJ subquery in WHERE
+
+let $c11=
+ o_orderDATE between '1992-01-01' and '1992-06-30' and
+ o_custkey in (select c_custkey from customer
+ where c_nationkey in (1,2));
+
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+
+--echo # Should not use semi-join conversion because has ORDER BY ... LIMIT
+eval
+explain
+delete from orders where $c11
+order by o_totalprice limit 500;
+eval
+create table t as
+select * from orders where $c11;
+select o_orderkey, o_totalprice from t;
+eval
+delete from orders where $c11
+order by o_totalprice limit 500;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+insert into orders select * from t;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+drop table t;
+
+--echo # Should use semi-join converion
+eval
+explain
+delete from orders where $c11;
+eval
+create table t as
+select * from orders where $c11;
+select o_orderkey, o_totalprice from t;
+eval
+delete from orders where $c11;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+insert into orders select * from t;
+--sorted_result
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+drop table t;
+
+
+CREATE TABLE partsupp_small (
+ ps_partkey int(11) NOT NULL DEFAULT '0',
+ ps_suppkey int(11) NOT NULL DEFAULT '0',
+ ps_availqty int(11) DEFAULT NULL,
+ ps_supplycost double DEFAULT NULL,
+ ps_comment varchar(199) DEFAULT NULL,
+ PRIMARY KEY (ps_partkey,ps_suppkey),
+ KEY i_ps_partkey (ps_partkey),
+ KEY i_ps_suppkey (ps_suppkey)
+);
+
+create index i_ps_sup_part on partsupp_small(ps_suppkey, ps_partkey);
+insert into partsupp_small select * from partsupp where ps_partkey <50;
+analyze table partsupp_small persistent for all;
+
+--echo # LooseScan
+--echo # =========
+
+let $c12 = l_partkey in
+ (select ps_partkey from partsupp_small
+ where ps_suppkey in (1,2,3));
+
+eval
+explain
+select count(*) from lineitem where $c12;
+eval
+explain format=json
+select count(*) from lineitem where $c12;
+eval
+explain
+select l_partkey from lineitem where $c12;
+eval
+explain format=json
+select l_partkey from lineitem where $c12;
+eval
+select count(*) from lineitem where $c12;
+eval
+create table t as
+select * from lineitem where $c12;
+
+eval
+explain
+delete from lineitem where $c12;
+eval
+explain format=json
+delete from lineitem where $c12;
+eval
+delete from lineitem where $c12;
+eval
+select count(*) from lineitem where $c12;
+
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c12;
+
+drop table t;
+
+--echo # LooseScan PS
+--echo # ============
+
+eval
+prepare stmt from "
+delete from lineitem where $c12;
+";
+
+eval
+select count(*) from lineitem where $c12;
+eval
+create table t as
+select * from lineitem where $c12;
+execute stmt;
+eval
+select count(*) from lineitem where $c12;
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c12;
+
+eval
+create table r as
+select * from lineitem where $c12;
+execute stmt;
+eval
+select count(*) from lineitem where $c12;
+insert into lineitem select * from r;
+eval
+select count(*) from lineitem where $c12;
+
+drop tables r, t;
+deallocate prepare stmt;
+
+--echo # LooseScan SP
+--echo # ============
+
+eval
+create procedure p()
+delete from lineitem where $c12;
+
+eval
+select count(*) from lineitem where $c12;
+eval
+create table t as
+select * from lineitem where $c12;
+call p();
+eval
+select count(*) from lineitem where $c12;
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c12;
+
+eval
+create table r as
+select * from lineitem where $c12;
+call p();
+eval
+select count(*) from lineitem where $c12;
+insert into lineitem select * from r;
+eval
+select count(*) from lineitem where $c12;
+
+drop tables r, t;
+drop procedure p;
+
+--echo # DuplicateWeedout
+--echo # ================
+
+set @tmp_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='materialization=off';
+
+analyze table lineitem;
+analyze table orders;
+
+let $c13 = l_partkey in (
+ select ps_partkey
+ from partsupp_small join lineitem on ps_partkey=l_partkey
+ where ps_suppkey in (
+ select s_suppkey from supplier where s_suppkey < 2
+ )
+);
+
+eval
+explain
+select count(*) from lineitem where $c13;
+eval
+explain format=json
+select count(*) from lineitem where $c13;
+eval
+explain
+select l_partkey from lineitem where $c13;
+eval
+explain format=json
+select l_partkey from lineitem where $c13;
+eval
+select count(*) from lineitem where $c13;
+eval
+create table t as
+select * from lineitem where $c13;
+
+eval
+explain
+delete from lineitem where $c13;
+eval
+explain format=json
+delete from lineitem where $c13;
+eval
+delete from lineitem where $c13;
+eval
+select count(*) from lineitem where $c13;
+
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c13;
+
+drop table t;
+
+--echo # DuplicateWeedout PS
+--echo # ===================
+
+eval
+prepare stmt from "
+delete from lineitem where $c13;
+";
+
+eval
+select count(*) from lineitem where $c13;
+eval
+create table t as
+select * from lineitem where $c13;
+execute stmt;
+eval
+select count(*) from lineitem where $c13;
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c13;
+
+eval
+create table r as
+select * from lineitem where $c13;
+execute stmt;
+eval
+select count(*) from lineitem where $c13;
+insert into lineitem select * from r;
+eval
+select count(*) from lineitem where $c13;
+
+drop tables r, t;
+deallocate prepare stmt;
+
+--echo # DuplicateWeedout SP
+--echo # ===================
+
+eval
+create procedure p()
+delete from lineitem where $c13;
+
+eval
+select count(*) from lineitem where $c13;
+eval
+create table t as
+select * from lineitem where $c13;
+call p();
+eval
+select count(*) from lineitem where $c13;
+insert into lineitem select * from t;
+eval
+select count(*) from lineitem where $c13;
+
+eval
+create table r as
+select * from lineitem where $c13;
+call p();
+eval
+select count(*) from lineitem where $c13;
+insert into lineitem select * from r;
+eval
+select count(*) from lineitem where $c13;
+
+drop tables r, t;
+drop procedure p;
+
+set @@optimizer_switch=@tmp_optimizer_switch;
+
+drop table partsupp_small;
+
+DROP DATABASE dbt3_s001;
diff --git a/mysql-test/main/delete_use_source.result b/mysql-test/main/delete_use_source.result
index 0990a551db6..329203af613 100644
--- a/mysql-test/main/delete_use_source.result
+++ b/mysql-test/main/delete_use_source.result
@@ -49,7 +49,7 @@ rollback;
start transaction;
explain delete from v1 where (select count(*) from t1 b where b.c1=v1.c1) = 500 limit 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range c1 c1 4 NULL 600 Using where
+1 PRIMARY t1 range c1 c1 4 NULL 600 Using index condition; Using where
2 DEPENDENT SUBQUERY b ref c1 c1 4 test.t1.c1 167 Using index
delete from v1 where (select count(*) from t1 b where b.c1=v1.c1) = 500 limit 1;
affected rows: 1
@@ -65,7 +65,7 @@ rollback;
start transaction;
explain delete from v1 where (select count(*) from t1 b where b.c1=v1.c1) = 500;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL c1 NULL NULL NULL # Using where
+1 PRIMARY t1 range c1 c1 4 NULL # Using index condition; Using where
2 DEPENDENT SUBQUERY b ref c1 c1 4 test.t1.c1 # Using index
delete from v1 where (select count(*) from t1 b where b.c1=v1.c1) = 500 ;
affected rows: 500
@@ -154,3 +154,183 @@ set session sort_buffer_size = 1024;
delete from t1 where c1=0 and exists(select 'x' from t1 b where b.c1<10);
affected rows: 128000
drop table t1;
+#
+# MDEV-17954: multi-table DELETE with the same source and target
+#
+create table t1 (c1 int, c2 int, c3 int);
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+#
+# Single-table DELETE with the same source and target
+# handled as multi-table DELETE
+#
+explain delete from t1
+where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1 and a.c2 < 3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
+delete from t1
+where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1 and a.c2 < 3);
+select * from t1;
+c1 c2 c3
+1 3 3
+2 3 6
+2 4 7
+2 5 8
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+prepare stmt from "delete from t1
+where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1 and a.c2 < 3)";
+execute stmt;
+select * from t1;
+c1 c2 c3
+1 3 3
+2 3 6
+2 4 7
+2 5 8
+delete from t1;
+insert into t1 values
+(2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+c1 c2 c3
+2 3 6
+2 4 7
+2 5 8
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+#
+# Multi-table DELETE with the same source and target
+#
+create table t2 (c1 int, c2 int, c3 int);
+insert into t2 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,5,8);
+explain delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 7
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
+delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 4 7
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+prepare stmt from "delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1";
+execute stmt;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 4 7
+delete from t1;
+insert into t1 values
+(2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+c1 c2 c3
+2 4 7
+deallocate prepare stmt;
+explain delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+1 SIMPLE t2 ALL NULL NULL NULL NULL 7 Using where
+delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1;
+select * from t1;
+c1 c2 c3
+2 4 7
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+prepare stmt from "delete from t1 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1";
+execute stmt;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 4 7
+delete from t1;
+insert into t1 values
+(2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+c1 c2 c3
+2 4 7
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+explain delete from t1,t2 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1 and t2.c1 > 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 7 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
+delete from t1,t2 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1 and t2.c1 > 1;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 4 7
+select * from t2;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+delete from t1;
+insert into t1 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+delete from t2;
+insert into t2 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,5,8);
+prepare stmt from "delete from t1,t2 using t1,t2
+where t1.c2 = t2.c2 and t1.c1 > 1 and t2.c1 > 1";
+execute stmt;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 4 7
+select * from t2;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+delete from t1;
+insert into t1 values
+(1,2,2), (1,3,3), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+delete from t2;
+insert into t2 values
+(1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5);
+execute stmt;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+2 3 6
+2 4 7
+2 5 8
+select * from t2;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+2 1 4
+deallocate prepare stmt;
+drop table t1,t2;
diff --git a/mysql-test/main/delete_use_source.test b/mysql-test/main/delete_use_source.test
index 4aed00da375..9625431c1a8 100644
--- a/mysql-test/main/delete_use_source.test
+++ b/mysql-test/main/delete_use_source.test
@@ -135,3 +135,123 @@ set session sort_buffer_size = 1024;
delete from t1 where c1=0 and exists(select 'x' from t1 b where b.c1<10);
drop table t1;
+
+--echo #
+--echo # MDEV-17954: multi-table DELETE with the same source and target
+--echo #
+
+create table t1 (c1 int, c2 int, c3 int);
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+
+--echo #
+--echo # Single-table DELETE with the same source and target
+--echo # handled as multi-table DELETE
+--echo #
+
+let $q1=
+delete from t1
+ where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1 and a.c2 < 3);
+
+eval explain $q1;
+eval $q1;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+eval prepare stmt from "$q1";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+
+--echo #
+--echo # Multi-table DELETE with the same source and target
+--echo #
+
+create table t2 (c1 int, c2 int, c3 int);
+insert into t2 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,5,8);
+
+let $q2=
+delete from t1 using t1,t2
+ where t1.c2 = t2.c2 and t1.c1 > 1;
+
+eval explain $q2;
+eval $q2;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+eval prepare stmt from "$q2";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+let $q2=
+delete from t1 using t1,t2
+ where t1.c2 = t2.c2 and t1.c1 > 1;
+
+eval explain $q2;
+eval $q2;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+eval prepare stmt from "$q2";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 values
+ (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+
+let $q3=
+delete from t1,t2 using t1,t2
+ where t1.c2 = t2.c2 and t1.c1 > 1 and t2.c1 > 1;
+
+eval explain $q3;
+eval $q3;
+select * from t1;
+select * from t2;
+delete from t1;
+insert into t1 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+delete from t2;
+insert into t2 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,5,8);
+eval prepare stmt from "$q3";
+execute stmt;
+select * from t1;
+select * from t2;
+delete from t1;
+insert into t1 values
+ (1,2,2), (1,3,3), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
+delete from t2;
+insert into t2 values
+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5);
+execute stmt;
+select * from t1;
+select * from t2;
+deallocate prepare stmt;
+
+drop table t1,t2;
diff --git a/mysql-test/main/delete_use_source_engines.result b/mysql-test/main/delete_use_source_engines.result
new file mode 100644
index 00000000000..b1ad9c009d9
--- /dev/null
+++ b/mysql-test/main/delete_use_source_engines.result
@@ -0,0 +1,8870 @@
+set @save_default_engine=@@default_storage_engine;
+#######################################
+# #
+# Engine InnoDB #
+# #
+#######################################
+set global innodb_stats_persistent=1;
+set default_storage_engine=InnoDB;
+create table t1 (c1 integer, c2 integer, c3 integer);
+insert into t1(c1,c2,c3)
+values (1,1,1),(1,2,2),(1,3,3),
+(2,1,4),(2,2,5),(2,3,6),
+(2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create view v1 as select * from t1 where c2=2;
+#######################################
+# Test without any index #
+#######################################
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 12.00 3.12 5.56 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 12.50 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 24.50 3.12 1.02 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 11.67 3.12 5.71 Using where; Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 12.50 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 0.25 18.75 100.00 Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a index_subquery t1_c2 t1_c2 5 func 5 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 1.00 100.00 100.00 Using index
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 12.33 3.12 5.41 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 1.00 100.00 100.00 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 1.00 3.12 100.00 Using where; End temporary
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 1
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+#
+# Test on dynamic columns (blob)
+#
+create table assets (
+item_name varchar(32) primary key, -- A common attribute for all items
+dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets
+VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets
+VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+INSERT INTO assets
+VALUES ('Fridge',
+COLUMN_CREATE('color', 'white', 'warranty', '5 years'));
+INSERT INTO assets
+VALUES ('Microwave',
+COLUMN_CREATE('warranty', '3 years'));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge white
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+UPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, 'color')
+WHERE item_name='Fridge';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+DELETE FROM assets
+WHERE item_name in
+(select b.item_name from assets b
+where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+DELETE FROM assets WHERE item_name='Microwave';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+drop table assets ;
+#
+# Test on fulltext columns
+#
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+('MySQL vs MariaDB database'),
+('Oracle vs MariaDB database'),
+('PostgreSQL vs MariaDB database'),
+('MariaDB overview'),
+('Foreign keys'),
+('Primary keys'),
+('Indexes'),
+('Transactions'),
+('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+MySQL vs MariaDB database
+Oracle vs MariaDB database
+PostgreSQL vs MariaDB database
+DELETE FROM ft2 WHERE MATCH(copy) AGAINST('database');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+drop table ft2;
+#######################################
+# #
+# Engine Aria #
+# #
+#######################################
+set default_storage_engine=Aria;
+create table t1 (c1 integer, c2 integer, c3 integer);
+insert into t1(c1,c2,c3)
+values (1,1,1),(1,2,2),(1,3,3),
+(2,1,4),(2,2,5),(2,3,6),
+(2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create view v1 as select * from t1 where c2=2;
+#######################################
+# Test without any index #
+#######################################
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 12.67 3.12 5.26 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 25.00 100.00 12.00 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 22.67 3.12 1.47 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 62.50 62.50 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func # 1.00 100.00 100.00
+2 MATERIALIZED a ALL NULL NULL NULL NULL # 32.00 62.50 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 3.91 3.12 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 5.00 25.00 20.00 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # 32.00 100.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 11.67 3.12 5.71 Using where; Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 27.00 100.00 14.81 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 0.25 18.75 100.00 Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using where; FirstMatch(t1)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a index_subquery t1_c2 t1_c2 5 func 5 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 1.00 100.00 100.00 Using index
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8
+1 PRIMARY a ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8
+1 PRIMARY a ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 5 NULL # Using index condition
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 # Using index; FirstMatch(t1)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a index t1_c2 t1_c2 10 NULL # Using where; Using index; LooseScan
+1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY a index t1_c2 t1_c2 10 NULL # 16.00 20.00 25.00 Using where; Using index; LooseScan
+1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 # 5.00 4.76 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using where
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using index; FirstMatch(t1)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using where
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func # Using where; Using index
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # 1.00 100.00 100.00 Using where
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func # 1.00 100.00 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # 32.00 100.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 12.00 3.12 5.56 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 4.00 100.00 100.00 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 1.00 3.12 25.00 Using where; End temporary
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 1
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 62.50 62.50 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func # 1.00 100.00 100.00
+2 MATERIALIZED a ALL NULL NULL NULL NULL # 32.00 62.50 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 #
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 #
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 3.91 3.12 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 6.00 25.00 16.67 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 # 1.00 100.00 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+#
+# Test on dynamic columns (blob)
+#
+create table assets (
+item_name varchar(32) primary key, -- A common attribute for all items
+dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets
+VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets
+VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+INSERT INTO assets
+VALUES ('Fridge',
+COLUMN_CREATE('color', 'white', 'warranty', '5 years'));
+INSERT INTO assets
+VALUES ('Microwave',
+COLUMN_CREATE('warranty', '3 years'));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge white
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+UPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, 'color')
+WHERE item_name='Fridge';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+DELETE FROM assets
+WHERE item_name in
+(select b.item_name from assets b
+where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+DELETE FROM assets WHERE item_name='Microwave';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+drop table assets ;
+#
+# Test on fulltext columns
+#
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+('MySQL vs MariaDB database'),
+('Oracle vs MariaDB database'),
+('PostgreSQL vs MariaDB database'),
+('MariaDB overview'),
+('Foreign keys'),
+('Primary keys'),
+('Indexes'),
+('Transactions'),
+('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+MySQL vs MariaDB database
+Oracle vs MariaDB database
+PostgreSQL vs MariaDB database
+DELETE FROM ft2 WHERE MATCH(copy) AGAINST('database');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+drop table ft2;
+#######################################
+# #
+# Engine MyISAM #
+# #
+#######################################
+set default_storage_engine=MyISAM;
+create table t1 (c1 integer, c2 integer, c3 integer);
+insert into t1(c1,c2,c3)
+values (1,1,1),(1,2,2),(1,3,3),
+(2,1,4),(2,2,5),(2,3,6),
+(2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create view v1 as select * from t1 where c2=2;
+#######################################
+# Test without any index #
+#######################################
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 12.67 3.12 5.26 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 25.00 100.00 12.00 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 22.67 3.12 1.47 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 62.50 62.50 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func # 1.00 100.00 100.00
+2 MATERIALIZED a ALL NULL NULL NULL NULL # 32.00 62.50 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 3.91 3.12 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 5.00 25.00 20.00 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # 32.00 100.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 11.67 3.12 5.71 Using where; Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 1 Using index; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 Using index; FirstMatch(t1)
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 29.00 100.00 13.79 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c1 5 0.25 18.75 100.00 Using index; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a index_subquery t1_c2 t1_c2 5 func 5 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 1.00 100.00 100.00 Using index
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8
+1 PRIMARY a ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8
+1 PRIMARY a ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL # Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 # Using index; FirstMatch(t1)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a index t1_c2 t1_c2 10 NULL # Using where; Using index; LooseScan
+1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY a index t1_c2 t1_c2 10 NULL # 16.00 20.00 25.00 Using where; Using index; LooseScan
+1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 # 5.00 5.00 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using where
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using index; FirstMatch(t1)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # Using where
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func # Using where; Using index
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # Using where
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const # 1.00 100.00 100.00 Using where
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func # 1.00 100.00 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL # 32.00 100.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+analyze delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 9.38 9.38 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 13.33 3.12 5.00 Using where; FirstMatch(t1)
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+analyze delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 4.00 100.00 100.00 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 1.00 3.12 25.00 Using where; End temporary
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 1
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+# Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+analyze delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 32.00 100.00 25.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 32.00 25.00 3.12 Using where
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED a ALL NULL NULL NULL NULL #
+analyze delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 62.50 62.50 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func # 1.00 100.00 100.00
+2 MATERIALIZED a ALL NULL NULL NULL NULL # 32.00 62.50 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 #
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 #
+analyze delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL # 32.00 3.91 3.12 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 3.00 25.00 33.33 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 # 1.00 100.00 100.00
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+#
+# Test on dynamic columns (blob)
+#
+create table assets (
+item_name varchar(32) primary key, -- A common attribute for all items
+dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets
+VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets
+VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+INSERT INTO assets
+VALUES ('Fridge',
+COLUMN_CREATE('color', 'white', 'warranty', '5 years'));
+INSERT INTO assets
+VALUES ('Microwave',
+COLUMN_CREATE('warranty', '3 years'));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge white
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+UPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, 'color')
+WHERE item_name='Fridge';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+Thinkpad Laptop black
+DELETE FROM assets
+WHERE item_name in
+(select b.item_name from assets b
+where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+Microwave NULL
+DELETE FROM assets WHERE item_name='Microwave';
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets ORDER BY item_name;
+item_name color
+Fridge NULL
+MariaDB T-shirt blue
+drop table assets ;
+#
+# Test on fulltext columns
+#
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+('MySQL vs MariaDB database'),
+('Oracle vs MariaDB database'),
+('PostgreSQL vs MariaDB database'),
+('MariaDB overview'),
+('Foreign keys'),
+('Primary keys'),
+('Indexes'),
+('Transactions'),
+('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+MySQL vs MariaDB database
+Oracle vs MariaDB database
+PostgreSQL vs MariaDB database
+DELETE FROM ft2 WHERE MATCH(copy) AGAINST('database');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+drop table ft2;
+#######################################
+# #
+# Engine MEMORY #
+# #
+#######################################
+set default_storage_engine=MEMORY;
+create table t1 (c1 integer, c2 integer, c3 integer);
+insert into t1(c1,c2,c3)
+values (1,1,1),(1,2,2),(1,3,3),
+(2,1,4),(2,2,5),(2,3,6),
+(2,4,7),(2,5,8);
+insert into t1 select c1+10,c2,c3+10 from t1;
+insert into t1 select c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create view v1 as select * from t1 where c2=2;
+#######################################
+# Test without any index #
+#######################################
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+affected rows: 2
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+affected rows: 2
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 2 FirstMatch(t1)
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c3 2 FirstMatch(t1)
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
+1 PRIMARY a ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a ALL t1_c2 NULL NULL NULL 32 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 2
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 2
+delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL t1_c2 NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL t1_c2 NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const 2 Using where
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const 2 FirstMatch(t1)
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,const 2 Using where
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func 2 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+#
+# Delete with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+explain select * from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+explain delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+delete from t1 where c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 4
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+explain select * from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where c1 = 1 and exists (select 'X' from t1 a where a.c1 = t1.c2);
+affected rows: 2
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 = 3;
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 4 7
+2 5 8
+21 2 21
+21 4 23
+22 2 24
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 4 33
+32 2 34
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+delete from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with IN predicand over the updated table in WHERE
+#
+create table tmp as select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+explain select * from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+explain delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c1 1 Using where; End temporary
+delete from t1 where c3 in (select distinct a.c1 from t1 a where t1.c2=a.c2);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 3 3
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit - can be deleted
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; Start temporary
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.a.c2 1 Using where; End temporary
+delete from t1 where c1 in (select a.c2 from t1 a where a.c2 = t1.c3) limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete with a limit and an order by
+#
+create table tmp as select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+explain select * from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 32 Using filesort
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+explain delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using where
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete: 2 execution of PS
+#
+prepare create_tmp_stmt from
+"create table tmp as select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+prepare delete_t1_stmt from
+"delete from t1 where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=5;
+execute create_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 6 38
+prepare insert_tmp_stmt from
+"insert into tmp(c1,c2,c3) select * from t1
+ where c2=(select a.c3 from t1 a where a.c3 = ?)";
+set @a:=2;
+execute insert_tmp_stmt using @a;
+execute delete_t1_stmt using @a;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+2 1 4
+2 3 6
+2 4 7
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+drop table tmp;
+#
+# Delete in stored procedure
+#
+create procedure sp()
+begin
+delete from t1 where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+end
+//
+create table tmp as select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+insert into tmp(c1,c2,c3) select * from t1
+where c1 in (select a.c2 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 1;
+CALL sp;
+select * from t1;
+c1 c2 c3
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop procedure sp;
+drop table tmp;
+#
+# Delete in stored function
+#
+create function f1(IN a INT) returns int
+begin
+delete from t1 where c3 < a order by c3 limit 1;
+return 1;
+end;//
+set @a:=7;
+create table tmp as select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+insert into tmp(c1,c2,c3) select * from t1 where c3 < @a
+order by c3 limit 1;
+select f1(@a);
+f1(@a)
+1
+select * from t1;
+c1 c2 c3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop function f1;
+drop table tmp;
+#
+# Delete in trigger
+#
+create table t2 (c1 integer);
+insert into t2(c1) values (1), (2), (3), (4), (5), (6), (7), (8);
+CREATE TABLE cnt(del integer);
+INSERT INTO cnt VALUES(0);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+UPDATE cnt SET del=del+1;
+CREATE TRIGGER tr2 AFTER DELETE ON t1 FOR EACH ROW
+DELETE FROM t2 WHERE c1> (SELECT count(*)-1 FROM t2);
+CREATE TABLE tmp as SELECT * FROM t1 WHERE c2>=3;
+DELETE FROM t1 WHERE c2>=3;
+affected rows: 20
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+11 1 11
+11 2 12
+12 1 14
+12 2 15
+2 1 4
+2 2 5
+21 2 21
+22 2 24
+31 2 31
+32 2 34
+SELECT * FROM t2;
+c1
+SELECT * FROM cnt;
+del
+20
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+drop table t2, cnt, tmp;
+#
+Delete with a reference to view in subquery
+#
+create table tmp as select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+explain select * from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+explain delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+delete from t1 where t1.c2 in ( select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 8
+select * from t1;
+c1 c2 c3
+1 1 1
+1 3 3
+11 1 11
+11 3 13
+12 1 14
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 3 22
+21 4 23
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 3 32
+31 4 33
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+explain select * from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+explain delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+delete from v1 where v1.c1 in
+(select max(a.c1) from t1 a where a.c2 = v1.c2) and c3 = 5;
+affected rows: 0
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+#
+# Delete from view using reference
+# to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3)
+and c1 = 2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+select * from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+insert into t1(c1,c2,c3) select c1,c2,c3 from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+set @@default_storage_engine=@save_default_engine;
+#
+# End of 11.0 tests
+#
diff --git a/mysql-test/main/delete_use_source_engines.test b/mysql-test/main/delete_use_source_engines.test
new file mode 100644
index 00000000000..1a0d98f8399
--- /dev/null
+++ b/mysql-test/main/delete_use_source_engines.test
@@ -0,0 +1,42 @@
+--source include/have_innodb.inc
+
+set @save_default_engine=@@default_storage_engine;
+
+--echo #######################################
+--echo # #
+--echo # Engine InnoDB #
+--echo # #
+--echo #######################################
+set global innodb_stats_persistent=1;
+set default_storage_engine=InnoDB;
+--source include/delete_use_source_innodb.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine Aria #
+--echo # #
+--echo #######################################
+set default_storage_engine=Aria;
+--source include/delete_use_source.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine MyISAM #
+--echo # #
+--echo #######################################
+set default_storage_engine=MyISAM;
+--source include/delete_use_source.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine MEMORY #
+--echo # #
+--echo #######################################
+set default_storage_engine=MEMORY;
+--source include/delete_use_source_memory.inc
+
+set @@default_storage_engine=@save_default_engine;
+
+--echo #
+--echo # End of 11.0 tests
+--echo #
diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result
index 112a72a2bf6..7203c9bf67a 100644
--- a/mysql-test/main/derived.result
+++ b/mysql-test/main/derived.result
@@ -1478,3 +1478,336 @@ drop table t1;
#
# End of 11.0 tests
#
+#
+# MDEV-28883: single/multi-table UPDATE/DELETE whose WHERE condition
+# contains subquery from mergeable derived table
+# that uses the updated/deleted table
+#
+create table t1 (pk int, a int);
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+explain update t1 set a = 10
+where a = ( select * from (select a from t1) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where
+update t1 set a = 10
+where a = ( select * from (select a from t1) dt where dt.a > 7);
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+4 10
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "update t1 set a = 10
+where a = ( select * from (select a from t1) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+4 10
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+4 10
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+explain update t1 set a = 10
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
+update t1 set a = 10
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+select * from t1;
+pk a
+4 9
+3 10
+1 10
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+prepare stmt from "update t1 set a = 10
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2";
+execute stmt;
+select * from t1;
+pk a
+4 9
+3 10
+1 10
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+4 9
+3 10
+1 10
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+explain delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where
+delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 7);
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+explain delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 5)
+returning pk, a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
+delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 5)
+returning pk, a;
+pk a
+4 9
+select * from t1;
+pk a
+3 1
+1 3
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+prepare stmt from "delete from t1
+where a = ( select * from (select a from t1) dt where dt.a > 5)
+returning pk, a";
+execute stmt;
+pk a
+4 9
+select * from t1;
+pk a
+3 1
+1 3
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+pk a
+4 9
+select * from t1;
+pk a
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+explain delete from t1
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using filesort
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where
+delete from t1
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+select * from t1;
+pk a
+2 7
+4 9
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "delete from t1
+where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2";
+execute stmt;
+select * from t1;
+pk a
+2 7
+4 9
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+execute stmt;
+select * from t1;
+pk a
+2 7
+4 9
+deallocate prepare stmt;
+create table t2 (pk int, a int);
+insert into t2 values (1,3), (2, 7), (3,1), (4,9);
+create table t3 (a int);
+insert into t3 VALUES (0),(1);
+explain update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+select * from t1;
+pk a
+2 7
+4 9
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+4 9
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+4 9
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+explain update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where
+update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+4 9
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "update t1,t3 set t1.a = 1
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+4 9
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+4 9
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+insert into t3 values (9), (10), (7);
+explain delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where
+delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t1) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+3 1
+1 3
+deallocate prepare stmt;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+explain delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where
+delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+prepare stmt from "delete from t1 using t1,t3
+where t1.a=t3.a and
+t1.a = ( select * from (select a from t2) dt where dt.a > 7)";
+execute stmt;
+select * from t1;
+pk a
+1 3
+2 7
+3 1
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+pk a
+3 1
+1 3
+deallocate prepare stmt;
+drop table t1,t2,t3;
+# End of MariaDB 11.1 tests
diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test
index e5f01e15821..dceae7a8c8f 100644
--- a/mysql-test/main/derived.test
+++ b/mysql-test/main/derived.test
@@ -1246,3 +1246,211 @@ drop table t1;
--echo #
--echo # End of 11.0 tests
--echo #
+
+--echo #
+--echo # MDEV-28883: single/multi-table UPDATE/DELETE whose WHERE condition
+--echo # contains subquery from mergeable derived table
+--echo # that uses the updated/deleted table
+--echo #
+
+create table t1 (pk int, a int);
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+
+let $q1=
+update t1 set a = 10
+ where a = ( select * from (select a from t1) dt where dt.a > 7);
+
+eval explain $q1;
+eval $q1;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q1";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+
+let $q2=
+update t1 set a = 10
+ where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+eval explain $q2;
+eval $q2;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+eval prepare stmt from "$q2";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+
+let $q3=
+delete from t1
+ where a = ( select * from (select a from t1) dt where dt.a > 7);
+
+eval explain $q3;
+eval $q3;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q3";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+
+let $q4=
+delete from t1
+ where a = ( select * from (select a from t1) dt where dt.a > 5)
+returning pk, a;
+
+eval explain $q4;
+eval $q4;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+eval prepare stmt from "$q4";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+
+let $q5=
+delete from t1
+ where a <> ( select * from (select a from t1) dt where dt.a > 7)
+order by a limit 2;
+eval explain $q5;
+eval $q5;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q5";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+create table t2 (pk int, a int);
+insert into t2 values (1,3), (2, 7), (3,1), (4,9);
+create table t3 (a int);
+insert into t3 VALUES (0),(1);
+
+let $q6=
+update t1,t3 set t1.a = 1
+ where t1.a=t3.a and
+ t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+
+eval explain $q6;
+eval $q6;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q6";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+
+let $q7=
+update t1,t3 set t1.a = 1
+ where t1.a=t3.a and
+ t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+
+eval explain $q7;
+eval $q7;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q7";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+insert into t3 values (9), (10), (7);
+
+let $q8=
+delete from t1 using t1,t3
+ where t1.a=t3.a and
+ t1.a = ( select * from (select a from t1) dt where dt.a > 7);
+
+eval explain $q8;
+eval $q8;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q8";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+
+let $q9=
+delete from t1 using t1,t3
+ where t1.a=t3.a and
+ t1.a = ( select * from (select a from t2) dt where dt.a > 7);
+
+eval explain $q9;
+eval $q9;
+select * from t1;
+delete from t1;
+insert into t1 values (1,3), (2, 7), (3,1), (4,9);
+eval prepare stmt from "$q9";
+execute stmt;
+select * from t1;
+delete from t1;
+insert into t1 value (4,9), (3,1), (1,3);
+execute stmt;
+select * from t1;
+deallocate prepare stmt;
+
+
+drop table t1,t2,t3;
+
+--echo # End of MariaDB 11.1 tests
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index ddc6505a178..544c8ace7b7 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -13098,7 +13098,7 @@ DROP TABLE t1;
#
CREATE TABLE t1 (f1 text, f2 int);
INSERT INTO t1 VALUES ('x',1), ('y',2);
-CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t;
+CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 GROUP BY f2) AS t;
UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
EXPLAIN FORMAT=JSON UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
EXPLAIN
@@ -13135,19 +13135,24 @@ EXPLAIN
"query_block": {
"select_id": 3,
"cost": "COST_REPLACED",
- "nested_loop": [
- {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "loops": 1,
- "rows": 2,
- "cost": "COST_REPLACED",
- "filtered": 100,
- "attached_condition": "t1.f2 < 2"
- }
+ "filesort": {
+ "sort_key": "t1.f2",
+ "temporary_table": {
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "loops": 1,
+ "rows": 2,
+ "cost": "COST_REPLACED",
+ "filtered": 100,
+ "attached_condition": "t1.f2 < 2"
+ }
+ }
+ ]
}
- ]
+ }
}
}
}
@@ -22605,3 +22610,20 @@ id select_type table type possible_keys key key_len ref rows Extra
drop view v1;
drop table t1;
# End of 10.4 tests
+#
+# MDEV-28958: condition pushable into view after simplification
+# contains constant TRUE/FALSE as subformula
+#
+create table t1 (c1 int);
+insert into t1 values (3), (7), (1), (3), (1), (3);
+create table t2 (c2 int);
+insert into t2 values (3), (5), (7), (3);
+create view v1 as select * from t1 group by c1;
+create view v2 as select c1 as a, c2 as b from v1,t2 where c1=c2;
+select * from v2 group by a,b having a=b or b > a+10;
+a b
+3 3
+7 7
+drop view v1,v2;
+drop table t1,t2;
+# End of 10.7 tests
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 26b44488e1d..d77e0210eae 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -2219,7 +2219,7 @@ DROP TABLE t1;
CREATE TABLE t1 (f1 text, f2 int);
INSERT INTO t1 VALUES ('x',1), ('y',2);
-CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t;
+CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 GROUP BY f2) AS t;
let $q1 =
UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
eval $q1;
@@ -4144,3 +4144,24 @@ drop view v1;
drop table t1;
--echo # End of 10.4 tests
+
+--echo #
+--echo # MDEV-28958: condition pushable into view after simplification
+--echo # contains constant TRUE/FALSE as subformula
+--echo #
+
+create table t1 (c1 int);
+insert into t1 values (3), (7), (1), (3), (1), (3);
+
+create table t2 (c2 int);
+insert into t2 values (3), (5), (7), (3);
+
+create view v1 as select * from t1 group by c1;
+create view v2 as select c1 as a, c2 as b from v1,t2 where c1=c2;
+
+select * from v2 group by a,b having a=b or b > a+10;
+
+drop view v1,v2;
+drop table t1,t2;
+
+--echo # End of 10.7 tests
diff --git a/mysql-test/main/locale.result b/mysql-test/main/locale.result
index d29482ceffa..39f11053df6 100644
--- a/mysql-test/main/locale.result
+++ b/mysql-test/main/locale.result
@@ -306,3 +306,13 @@ date_format('2001-01-06', '%w %a %W', 'de_CH')
select date_format('2001-09-01', '%c %b %M', 'de_CH');
date_format('2001-09-01', '%c %b %M', 'de_CH')
9 Sep September
+#
+# MDEV-30789 Add Georgian error messages and locale
+#
+SET lc_messages=ka_GE;
+SELECT x;
+ERROR 42S22: უცნობი სვეტი 'x' 'field list'-ში
+SET lc_messages=DEFAULT;
+#
+# End of 10.11 tests
+#
diff --git a/mysql-test/main/locale.test b/mysql-test/main/locale.test
index a9a507bc387..9f4ceb270d9 100644
--- a/mysql-test/main/locale.test
+++ b/mysql-test/main/locale.test
@@ -181,3 +181,18 @@ select date_format('2001-10-01', '%c %b %M', 'rm_CH');
select date_format('2001-12-01', '%c %b %M', 'rm_CH');
select date_format('2001-01-06', '%w %a %W', 'de_CH');
select date_format('2001-09-01', '%c %b %M', 'de_CH');
+
+
+--echo #
+--echo # MDEV-30789 Add Georgian error messages and locale
+--echo #
+
+SET lc_messages=ka_GE;
+--error ER_BAD_FIELD_ERROR
+SELECT x;
+
+SET lc_messages=DEFAULT;
+
+--echo #
+--echo # End of 10.11 tests
+--echo #
diff --git a/mysql-test/main/log_state.result b/mysql-test/main/log_state.result
index 5e7aac81b0c..18c8da708a9 100644
--- a/mysql-test/main/log_state.result
+++ b/mysql-test/main/log_state.result
@@ -243,7 +243,7 @@ rows_examined sql_text
4 UPDATE t1 SET a=a+sleep(.02) WHERE a>2
8 UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC
1 UPDATE t2 set b=b+sleep(.02) limit 1
-4 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
+6 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2
disconnect con2;
connection default;
diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result
index 1eecb3e34ca..7144fd1d349 100644
--- a/mysql-test/main/merge.result
+++ b/mysql-test/main/merge.result
@@ -3898,9 +3898,6 @@ DROP TABLE t1;
DROP TABLE m1;
set global default_storage_engine=@save_default_storage_engine;
#
-# End of 10.0 tests
-#
-#
# MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results
#
create table t (a int, key(a desc)) engine=myisam;
@@ -3967,3 +3964,12 @@ DROP TABLE tm, t1, t2;
#
# End of 11.0 tests
#
+#
+# MDEV-29174: UPDATE of view that uses MERGE table
+#
+CREATE TABLE t1 (a int) ENGINE=MERGE;
+CREATE VIEW v1 AS SELECT a FROM t1;
+UPDATE v1 SET a=0;
+DROP VIEW v1;
+DROP TABLE t1;
+# End of 11.1 tests
diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test
index 6b88d427fb4..f8f421994e9 100644
--- a/mysql-test/main/merge.test
+++ b/mysql-test/main/merge.test
@@ -2860,10 +2860,6 @@ set global default_storage_engine=@save_default_storage_engine;
--source include/wait_until_count_sessions.inc
--echo #
---echo # End of 10.0 tests
---echo #
-
---echo #
--echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results
--echo #
create table t (a int, key(a desc)) engine=myisam;
@@ -2925,3 +2921,14 @@ DROP TABLE tm, t1, t2;
--echo #
--echo # End of 11.0 tests
--echo #
+--echo #
+--echo # MDEV-29174: UPDATE of view that uses MERGE table
+--echo #
+
+CREATE TABLE t1 (a int) ENGINE=MERGE;
+CREATE VIEW v1 AS SELECT a FROM t1;
+UPDATE v1 SET a=0;
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo # End of 11.1 tests
diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result
index bf011f66be0..2364ee732ce 100644
--- a/mysql-test/main/multi_update.result
+++ b/mysql-test/main/multi_update.result
@@ -441,12 +441,10 @@ create table t1 (col1 int);
create table t2 (col1 int);
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table t1,t2;
create table t1(a int);
create table t2(a int);
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1, 2), (2, 3), (3, 4);
@@ -1271,7 +1269,7 @@ EXPLAIN
DROP TABLES t1, t2;
# End of 10.3 tests
#
-# MDEV-28538: multi-table UPDATE/DELETE with possible exists-to-in
+# MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
#
create table t1 (c1 int, c2 int, c3 int, index idx(c2));
insert into t1 values
diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test
index b9ceb458db6..325f63f696f 100644
--- a/mysql-test/main/multi_update.test
+++ b/mysql-test/main/multi_update.test
@@ -391,7 +391,6 @@ drop table t1, t2, t3;
create table t1 (col1 int);
create table t2 (col1 int);
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
--- error ER_UPDATE_TABLE_USED
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
drop table t1,t2;
@@ -400,7 +399,6 @@ drop table t1,t2;
#
create table t1(a int);
create table t2(a int);
---error ER_UPDATE_TABLE_USED
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
drop table t1, t2;
# End of 4.1 tests
@@ -1137,7 +1135,7 @@ DROP TABLES t1, t2;
--echo # End of 10.3 tests
--echo #
---echo # MDEV-28538: multi-table UPDATE/DELETE with possible exists-to-in
+--echo # MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
--echo #
create table t1 (c1 int, c2 int, c3 int, index idx(c2));
diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result
index c8c26d76a70..28107af3770 100644
--- a/mysql-test/main/myisam_explain_non_select_all.result
+++ b/mysql-test/main/myisam_explain_non_select_all.result
@@ -218,18 +218,17 @@ INSERT INTO t2 VALUES (1), (2), (3);
#
EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
-Handler_read_rnd_next 1
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
@@ -248,7 +247,8 @@ Handler_read_rnd_next 5
# Status of testing query execution:
Variable_name Value
Handler_read_key 4
-Handler_read_rnd_next 5
+Handler_read_rnd 3
+Handler_read_rnd_next 9
Handler_update 3
DROP TABLE t1, t2;
@@ -264,13 +264,13 @@ INSERT INTO t2 VALUES (1), (2), (3);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t1)
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1)
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
# Status of EXPLAIN EXTENDED query
@@ -901,14 +901,14 @@ INSERT INTO t2 VALUES (1), (2), (3), (1000);
#
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1)
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1)
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
@@ -987,14 +987,14 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
#
EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; FirstMatch(t1)
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1)
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
@@ -2498,9 +2498,9 @@ DROP TABLE t1;
#57
CREATE TABLE t1(f1 INT);
EXPLAIN EXTENDED UPDATE t1 SET f2=1 ORDER BY f2;
-ERROR 42S22: Unknown column 'f2' in 'order clause'
+ERROR 42S22: Unknown column 'f2' in 'field list'
UPDATE t1 SET f2=1 ORDER BY f2;
-ERROR 42S22: Unknown column 'f2' in 'order clause'
+ERROR 42S22: Unknown column 'f2' in 'field list'
DROP TABLE t1;
#62
CREATE TABLE t1 (a INT);
@@ -2824,14 +2824,14 @@ INSERT INTO t2 VALUES (1), (2), (3);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY <derived3> unique_subquery distinct_key distinct_key 5 func 1
+1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1
3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 DEPENDENT SUBQUERY <derived3> unique_subquery distinct_key distinct_key 5 func 1 100.00
+1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
# Status of EXPLAIN EXTENDED query
Variable_name Value
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index 41e2afbd43b..634ef3343a4 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -4262,6 +4262,16 @@ QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
explain delete from t0 where t0.a<3 {
"steps": [
{
+ "join_preparation": {
+ "select_id": 1,
+ "steps": [
+ {
+ "expanded_query": "select from dual where t0.a < 3"
+ }
+ ]
+ }
+ },
+ {
"table": "t0",
"range_analysis": {
"table_scan": {
@@ -4293,7 +4303,7 @@ explain delete from t0 where t0.a<3 {
},
"group_index_range": {
"chosen": false,
- "cause": "no join"
+ "cause": "no group by or distinct"
},
"chosen_range_access_summary": {
"range_access_plan": {
@@ -4336,7 +4346,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"select_id": 1,
"steps": [
{
- "expanded_query": "select NULL AS `NULL` from t0 join t1 where t0.a = t1.a and t1.a < 3"
+ "expanded_query": "select from t0 join t1 where t0.a = t1.a and t1.a < 3"
}
]
}
@@ -4457,6 +4467,16 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
}
},
{
+ "table": "t0",
+ "rowid_filters": [
+ {
+ "key": "a",
+ "build_cost": 0.001129926,
+ "rows": 3
+ }
+ ]
+ },
+ {
"selectivity_for_indexes": [
{
"index_name": "a",
@@ -4522,6 +4542,16 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
}
},
{
+ "table": "t1",
+ "rowid_filters": [
+ {
+ "key": "a",
+ "build_cost": 0.001129926,
+ "rows": 3
+ }
+ ]
+ },
+ {
"selectivity_for_indexes": [
{
"index_name": "a",
diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result
index 96f5d9a49c3..a6d148679b6 100644
--- a/mysql-test/main/order_by.result
+++ b/mysql-test/main/order_by.result
@@ -981,13 +981,13 @@ ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
-ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+ERROR 42S22: Unknown column 'MissingCol' in 'field list'
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
-ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+ERROR 42S22: Unknown column 'MissingCol' in 'field list'
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
-ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+ERROR 42S22: Unknown column 'MissingCol' in 'field list'
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
-ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+ERROR 42S22: Unknown column 'MissingCol' in 'field list'
DROP TABLE bug25126;
CREATE TABLE t1 (a int);
SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1;
diff --git a/mysql-test/main/partition_charset.result b/mysql-test/main/partition_charset.result
index f8f75e8bee7..a0019dd8fc3 100644
--- a/mysql-test/main/partition_charset.result
+++ b/mysql-test/main/partition_charset.result
@@ -20,3 +20,24 @@ create table t1 (a varchar(1), primary key (a))
partition by list (ascii(a))
(partition p1 values in (65));
ERROR HY000: This partition function is not allowed
+#
+# Start of 10.9 tests
+#
+#
+# MDEV-30805 SIGSEGV in my_convert and UBSAN: member access within null pointer of type 'const struct MY_CHARSET_HANDLER' in my_convert
+#
+CREATE TABLE t1 (a CHAR CHARACTER SET ucs2)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN ('a'));
+ALTER TABLE t1 CHANGE COLUMN a a CHAR BINARY;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(1) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+ PARTITION BY RANGE COLUMNS(`a`)
+(PARTITION `p0` VALUES LESS THAN ('a') ENGINE = MyISAM)
+DROP TABLE t1;
+#
+# End of 10.9 tests
+#
diff --git a/mysql-test/main/partition_charset.test b/mysql-test/main/partition_charset.test
index 6842e5268fa..b8a17ce4fca 100644
--- a/mysql-test/main/partition_charset.test
+++ b/mysql-test/main/partition_charset.test
@@ -27,3 +27,23 @@ partition by list (ascii(a))
#insert into t1 values ('A');
#replace into t1 values ('A');
#drop table t1;
+
+--echo #
+--echo # Start of 10.9 tests
+--echo #
+
+--echo #
+--echo # MDEV-30805 SIGSEGV in my_convert and UBSAN: member access within null pointer of type 'const struct MY_CHARSET_HANDLER' in my_convert
+--echo #
+
+CREATE TABLE t1 (a CHAR CHARACTER SET ucs2)
+ PARTITION BY RANGE COLUMNS (a)
+ (PARTITION p0 VALUES LESS THAN ('a'));
+ALTER TABLE t1 CHANGE COLUMN a a CHAR BINARY;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.9 tests
+--echo #
+
diff --git a/mysql-test/main/partition_innodb2.result b/mysql-test/main/partition_innodb2.result
new file mode 100644
index 00000000000..4476eb91447
--- /dev/null
+++ b/mysql-test/main/partition_innodb2.result
@@ -0,0 +1,24 @@
+#
+# MDEV-30442: Assertion `!m_innodb' failed in ha_partition::cmp_ref on MULTI-DELETE
+#
+create table t1 (a int) engine=innodb;
+insert into t1 values (1),(2),(1),(2);
+create table t2 (
+a int,
+b int,
+key(a)
+) engine=innodb partition by list(a)
+(
+partition p0 values in (1),
+partition p1 values in (2),
+partition p2 values in (0,3,4,5,6,7,8,9)
+);
+insert into t2 select
+mod(seq, 10), seq from seq_1_to_50;
+explain
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ref a a 5 test.t1.a 1
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+drop table t1,t2;
diff --git a/mysql-test/main/partition_innodb2.test b/mysql-test/main/partition_innodb2.test
new file mode 100644
index 00000000000..7581c5db4ca
--- /dev/null
+++ b/mysql-test/main/partition_innodb2.test
@@ -0,0 +1,30 @@
+--source include/not_embedded.inc
+--source include/have_partition.inc
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-30442: Assertion `!m_innodb' failed in ha_partition::cmp_ref on MULTI-DELETE
+--echo #
+create table t1 (a int) engine=innodb;
+insert into t1 values (1),(2),(1),(2);
+
+create table t2 (
+ a int,
+ b int,
+ key(a)
+) engine=innodb partition by list(a)
+(
+ partition p0 values in (1),
+ partition p1 values in (2),
+ partition p2 values in (0,3,4,5,6,7,8,9)
+);
+
+insert into t2 select
+ mod(seq, 10), seq from seq_1_to_50;
+
+explain
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+
+drop table t1,t2;
diff --git a/mysql-test/main/partition_utf8-debug.result b/mysql-test/main/partition_utf8-debug.result
index db1396198ab..2b4982a3dcc 100644
--- a/mysql-test/main/partition_utf8-debug.result
+++ b/mysql-test/main/partition_utf8-debug.result
@@ -77,7 +77,7 @@ CREATE OR REPLACE TABLE t1 (a DATE) CHARACTER SET utf8
PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (FROM_DAYS(100)));
Warnings:
Note 1003 PARTITION BY LIST COLUMNS(`a`)
-(PARTITION `p0` VALUES IN (_utf8mb3 0x303030302d30302d3030) ENGINE = MyISAM)
+(PARTITION `p0` VALUES IN (_latin1 0x303030302d30302d3030) ENGINE = MyISAM)
SELECT PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
PARTITION_DESCRIPTION
'0000-00-00'
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index a147bdffc0f..9d6ac0b61ba 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -2322,5 +2322,14 @@ b
9
DROP TABLE t;
#
+# MDEV-30693: Assertion `dbl_records <= s->records' failed in apply_selectivity_for_table on SELECT
+#
+set @tmp_oucs= @@optimizer_use_condition_selectivity;
+CREATE TABLE t1 (c INT KEY) ENGINE=InnoDB;
+SELECT * FROM (SELECT * FROM t1) a JOIN (SELECT * FROM (SELECT * FROM t1 GROUP BY c) d WHERE c>1) b ON a.c=b.c;
+c c
+DROP TABLE t1;
+SET optimizer_use_condition_selectivity=1;
+#
# End of 11.0 tests
#
diff --git a/mysql-test/main/selectivity_innodb.test b/mysql-test/main/selectivity_innodb.test
index dc06287a1f9..efdb3c1853b 100644
--- a/mysql-test/main/selectivity_innodb.test
+++ b/mysql-test/main/selectivity_innodb.test
@@ -283,5 +283,14 @@ SELECT b FROM t WHERE a > 'a' GROUP BY b HAVING b >= 6 OR b <= 0;
DROP TABLE t;
--echo #
+--echo # MDEV-30693: Assertion `dbl_records <= s->records' failed in apply_selectivity_for_table on SELECT
+--echo #
+set @tmp_oucs= @@optimizer_use_condition_selectivity;
+CREATE TABLE t1 (c INT KEY) ENGINE=InnoDB;
+SELECT * FROM (SELECT * FROM t1) a JOIN (SELECT * FROM (SELECT * FROM t1 GROUP BY c) d WHERE c>1) b ON a.c=b.c;
+DROP TABLE t1;
+SET optimizer_use_condition_selectivity=1;
+
+--echo #
--echo # End of 11.0 tests
--echo #
diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index 2b3050c3ca2..e0cf1e61d95 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result
@@ -634,7 +634,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test
index 48ad7402755..578dbe86406 100644
--- a/mysql-test/main/subselect.test
+++ b/mysql-test/main/subselect.test
@@ -386,8 +386,13 @@ insert into t12 values (33, 10),(22, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
select * from t12;
--- error ER_UPDATE_TABLE_USED
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
+select * from t11;
+select * from t12;
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
-- error ER_SUBQUERY_NO_1_ROW
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result
index 3a144e70c75..3be4f07b8ca 100644
--- a/mysql-test/main/subselect_no_exists_to_in.result
+++ b/mysql-test/main/subselect_no_exists_to_in.result
@@ -638,7 +638,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result
index ca68e4d7e03..a47e2977774 100644
--- a/mysql-test/main/subselect_no_mat.result
+++ b/mysql-test/main/subselect_no_mat.result
@@ -641,7 +641,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result
index f9561178ca5..10153b0f60c 100644
--- a/mysql-test/main/subselect_no_opts.result
+++ b/mysql-test/main/subselect_no_opts.result
@@ -637,7 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result
index 813ca78703a..456d1dec846 100644
--- a/mysql-test/main/subselect_no_scache.result
+++ b/mysql-test/main/subselect_no_scache.result
@@ -640,7 +640,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result
index 19dae33c5c1..eba0f55a072 100644
--- a/mysql-test/main/subselect_no_semijoin.result
+++ b/mysql-test/main/subselect_no_semijoin.result
@@ -637,7 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+delete from t11;
+delete from t12;
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
diff --git a/mysql-test/main/update.result b/mysql-test/main/update.result
index f5edf1c6be3..c6c55da229e 100644
--- a/mysql-test/main/update.result
+++ b/mysql-test/main/update.result
@@ -399,7 +399,7 @@ update t1 set `*f2`=1;
drop table t1;
create table t1(f1 int);
update t1 set f2=1 order by f2;
-ERROR 42S22: Unknown column 'f2' in 'order clause'
+ERROR 42S22: Unknown column 'f2' in 'field list'
drop table t1;
CREATE TABLE t1 (
request_id int unsigned NOT NULL auto_increment,
@@ -734,3 +734,41 @@ UPDATE t1,t2 SET t1.i1 = -39 WHERE t2.d1 <> t1.i1 AND t2.d1 = t1.d2;
ERROR 22007: Incorrect datetime value: '19' for column `test`.`t1`.`i1` at row 1
DROP TABLE t1,t2;
# End of MariaDB 10.2 tests
+#
+# MDEV-29189: Second execution of SF using UPDATE?DELETE
+# after reported error by the first execution
+#
+CREATE TABLE t1 (c int);
+CREATE FUNCTION f1() RETURNS int
+BEGIN
+UPDATE t1 SET c=c+1;
+RETURN 1;
+END;//
+CREATE FUNCTION f2() RETURNS int
+BEGIN
+DELETE FROM t1 WHERE c < 7;
+RETURN 1;
+END;//
+INSERT INTO t1 VALUES (3), (7), (1);
+SELECT * FROM t1 WHERE f1() = 1;
+ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger
+SELECT f1();
+f1()
+1
+SELECT * FROM t1;
+c
+4
+8
+2
+SELECT * FROM t1 WHERE f2() = 1;
+ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger
+SELECT f2();
+f2()
+1
+SELECT * FROM t1;
+c
+8
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP TABLE t1;
+# End of MariaDB 10.10 tests
diff --git a/mysql-test/main/update.test b/mysql-test/main/update.test
index 8a6949447ee..88fea88f120 100644
--- a/mysql-test/main/update.test
+++ b/mysql-test/main/update.test
@@ -676,3 +676,41 @@ UPDATE t1,t2 SET t1.i1 = -39 WHERE t2.d1 <> t1.i1 AND t2.d1 = t1.d2;
DROP TABLE t1,t2;
--echo # End of MariaDB 10.2 tests
+
+--echo #
+--echo # MDEV-29189: Second execution of SF using UPDATE?DELETE
+--echo # after reported error by the first execution
+--echo #
+
+CREATE TABLE t1 (c int);
+
+DELIMITER //;
+CREATE FUNCTION f1() RETURNS int
+BEGIN
+ UPDATE t1 SET c=c+1;
+ RETURN 1;
+END;//
+CREATE FUNCTION f2() RETURNS int
+BEGIN
+ DELETE FROM t1 WHERE c < 7;
+ RETURN 1;
+END;//
+DELIMITER ;//
+
+INSERT INTO t1 VALUES (3), (7), (1);
+
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+SELECT * FROM t1 WHERE f1() = 1;
+SELECT f1();
+SELECT * FROM t1;
+
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+SELECT * FROM t1 WHERE f2() = 1;
+SELECT f2();
+SELECT * FROM t1;
+
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP TABLE t1;
+
+--echo # End of MariaDB 10.10 tests
diff --git a/mysql-test/main/update_single_to_multi.result b/mysql-test/main/update_single_to_multi.result
new file mode 100644
index 00000000000..679237837cc
--- /dev/null
+++ b/mysql-test/main/update_single_to_multi.result
@@ -0,0 +1,3860 @@
+DROP DATABASE IF EXISTS dbt3_s001;
+CREATE DATABASE dbt3_s001;
+use dbt3_s001;
+create index i_n_name on nation(n_name);
+analyze table
+nation, lineitem, customer, orders, part, supplier, partsupp, region
+persistent for all;
+Table Op Msg_type Msg_text
+dbt3_s001.nation analyze status Engine-independent statistics collected
+dbt3_s001.nation analyze status OK
+dbt3_s001.lineitem analyze status Engine-independent statistics collected
+dbt3_s001.lineitem analyze status OK
+dbt3_s001.customer analyze status Engine-independent statistics collected
+dbt3_s001.customer analyze status OK
+dbt3_s001.orders analyze status Engine-independent statistics collected
+dbt3_s001.orders analyze status OK
+dbt3_s001.part analyze status Engine-independent statistics collected
+dbt3_s001.part analyze status OK
+dbt3_s001.supplier analyze status Engine-independent statistics collected
+dbt3_s001.supplier analyze status OK
+dbt3_s001.partsupp analyze status Engine-independent statistics collected
+dbt3_s001.partsupp analyze status OK
+dbt3_s001.region analyze status Engine-independent statistics collected
+dbt3_s001.region analyze status OK
+# Pullout
+# =======
+explain
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+explain format=json
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.052271677,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_n_name"],
+ "key": "i_n_name",
+ "key_length": "26",
+ "used_key_parts": ["n_name"],
+ "ref": ["const"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.002024411,
+ "filtered": 100,
+ "index_condition": "nation.n_name = 'PERU'"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 1,
+ "rows": 6,
+ "cost": 0.008193756,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 108,
+ "selectivity_pct": 7.2
+ },
+ "loops": 6,
+ "rows": 15,
+ "cost": 0.04205351,
+ "filtered": 7.199999809,
+ "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
+ }
+ }
+ ]
+ }
+}
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+explain
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+explain format=json
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.052271677,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_n_name"],
+ "key": "i_n_name",
+ "key_length": "26",
+ "used_key_parts": ["n_name"],
+ "ref": ["const"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.002024411,
+ "filtered": 100,
+ "index_condition": "nation.n_name = 'PERU'"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 1,
+ "rows": 6,
+ "cost": 0.008193756,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 108,
+ "selectivity_pct": 7.2
+ },
+ "loops": 6,
+ "rows": 15,
+ "cost": 0.04205351,
+ "filtered": 7.199999809,
+ "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
+ }
+ }
+ ]
+ }
+}
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201218.06
+2880 145711.99
+3142 15980.15
+5382 138373.03
+5095 184533.99
+737 12934.85
+1729 12087.76
+5121 150284.57
+update orders set o_totalprice= o_totalprice+50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+explain
+update partsupp set ps_supplycost = ps_supplycost+2 where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+update partsupp set ps_supplycost = ps_supplycost+2 where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 359.84
+3 8 647.4
+4 1 446.37
+5 8 52.52
+6 1 644.13
+7 8 765.98
+8 1 959.34
+update partsupp set ps_supplycost = ps_supplycost-2 where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where (ps_partkey, ps_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 910 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+explain
+update partsupp set ps_supplycost = ps_supplycost+10 where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 Using where
+1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1
+update partsupp set ps_supplycost = ps_supplycost+10 where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 367.84
+3 8 655.4
+4 1 454.37
+5 8 60.52
+6 1 652.13
+7 8 773.98
+8 1 967.34
+update partsupp set ps_supplycost = ps_supplycost-10 where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where ps_partkey in (select p_partkey from part
+where p_retailprice between 901 and 910) and
+ps_suppkey in (select s_suppkey from supplier
+where s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+ps_partkey ps_suppkey ps_supplycost
+1 8 357.84
+3 8 645.4
+4 1 444.37
+5 8 50.52
+6 1 642.13
+7 8 763.98
+8 1 957.34
+explain
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+4996 1 0.01
+933 1 0.04
+2500 2 0.02
+2500 4 0.02
+explain
+update lineitem set l_tax = (l_tax*100+1)/100 where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+1 PRIMARY lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
+update lineitem set l_tax = (l_tax*100+1)/100 where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+4996 1 0.02
+933 1 0.05
+2500 2 0.03
+2500 4 0.03
+update lineitem set l_tax = (l_tax*100-1)/100 where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select l_orderkey, l_linenumber, l_tax from lineitem where l_orderkey in (select o_orderkey from orders
+where o_custkey in
+(select c_custkey from customer
+where c_nationkey in
+(select n_nationkey from nation
+where n_name='PERU'))
+and
+o_orderDATE between '1992-06-30' and '1992-12-31')
+and
+(l_partkey, l_suppkey) in
+(select p_partkey, s_suppkey from part, supplier
+where p_retailprice between 901 and 1000 and
+s_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+l_orderkey l_linenumber l_tax
+4996 1 0.01
+933 1 0.04
+2500 2 0.02
+2500 4 0.02
+# FirstMatch
+# ==========
+set optimizer_switch='materialization=off';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25 Using where
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (9%) Using where; FirstMatch(customer); Using rowid filter
+explain format=json
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.40015207,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY", "i_n_regionkey"],
+ "loops": 1,
+ "rows": 25,
+ "cost": 0.013945725,
+ "filtered": 40,
+ "attached_condition": "nation.n_regionkey in (1,2)"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 10,
+ "rows": 6,
+ "cost": 0.08009436,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 140,
+ "selectivity_pct": 9.333333333
+ },
+ "loops": 60,
+ "rows": 15,
+ "cost": 0.306111985,
+ "filtered": 6.666666508,
+ "attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
+ "first_match": "customer"
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+explain
+update customer set c_acctbal = c_acctbal+10 where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ALL PRIMARY,i_n_regionkey NULL NULL NULL 25 Using where
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (9%) Using where; FirstMatch(customer); Using rowid filter
+explain format=json
+update customer set c_acctbal = c_acctbal+10 where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.40015207,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "nation",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY", "i_n_regionkey"],
+ "loops": 1,
+ "rows": 25,
+ "cost": 0.013945725,
+ "filtered": 40,
+ "attached_condition": "nation.n_regionkey in (1,2)"
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "i_c_nationkey"],
+ "key": "i_c_nationkey",
+ "key_length": "5",
+ "used_key_parts": ["c_nationkey"],
+ "ref": ["dbt3_s001.nation.n_nationkey"],
+ "loops": 10,
+ "rows": 6,
+ "cost": 0.08009436,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ref",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "key": "i_o_custkey",
+ "key_length": "5",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["dbt3_s001.customer.c_custkey"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_o_orderdate",
+ "used_key_parts": ["o_orderDATE"]
+ },
+ "rows": 140,
+ "selectivity_pct": 9.333333333
+ },
+ "loops": 60,
+ "rows": 15,
+ "cost": 0.306111985,
+ "filtered": 6.666666508,
+ "attached_condition": "orders.o_orderDATE between '1992-10-09' and '1993-06-08'",
+ "first_match": "customer"
+ }
+ }
+ ]
+ }
+}
+update customer set c_acctbal = c_acctbal+10 where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3468.6
+Customer#000000106 3298.42
+Customer#000000017 16.34
+Customer#000000047 284.58
+Customer#000000092 1192.91
+Customer#000000101 7480.96
+Customer#000000022 601.98
+Customer#000000040 1345.3
+Customer#000000064 -636.64
+Customer#000000122 7875.46
+Customer#000000028 1017.18
+Customer#000000037 -907.75
+Customer#000000091 4653.14
+Customer#000000115 7518.92
+Customer#000000067 8176.59
+Customer#000000094 5510.11
+Customer#000000103 2767.45
+Customer#000000130 5083.58
+Customer#000000139 7907.78
+Customer#000000142 2219.81
+Customer#000000025 7143.7
+Customer#000000008 6829.74
+Customer#000000061 1546.24
+Customer#000000077 1748.87
+Customer#000000097 2174.48
+Customer#000000121 6438.32
+Customer#000000133 2324.67
+Customer#000000007 9571.95
+Customer#000000019 8924.71
+Customer#000000082 9478.34
+Customer#000000124 1852.49
+Customer#000000127 9290.71
+update customer set c_acctbal = c_acctbal-10 where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+set optimizer_switch='materialization=default';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; FirstMatch(customer); Using rowid filter
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+explain
+update customer set c_acctbal = c_acctbal+20 where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; FirstMatch(customer); Using rowid filter
+update customer set c_acctbal = c_acctbal+20 where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+Customer#000000008 6839.74
+Customer#000000035 1248.24
+Customer#000000061 1556.24
+Customer#000000097 2184.48
+Customer#000000121 6448.32
+Customer#000000133 2334.67
+update customer set c_acctbal = c_acctbal-20 where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where n_name='PERU')
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1993-01-08");
+c_name c_acctbal
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+# Materialization
+# ===============
+set optimizer_switch='firstmatch=off';
+explain
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
+3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+Customer#000000014 5266.3
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000038 6345.11
+Customer#000000098 -551.37
+Customer#000000113 2912
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+explain
+update customer set c_acctbal = c_acctbal+20 where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY nation range PRIMARY,i_n_name i_n_name 26 NULL 4 Using index condition
+1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
+3 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+update customer set c_acctbal = c_acctbal+20 where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+Customer#000000014 5286.3
+Customer#000000059 3478.6
+Customer#000000106 3308.42
+Customer#000000067 8186.59
+Customer#000000094 5520.11
+Customer#000000103 2777.45
+Customer#000000130 5093.58
+Customer#000000139 7917.78
+Customer#000000142 2229.81
+Customer#000000025 7153.7
+Customer#000000038 6365.11
+Customer#000000098 -531.37
+Customer#000000113 2932
+Customer#000000008 6839.74
+Customer#000000035 1248.24
+Customer#000000061 1556.24
+Customer#000000077 1758.87
+Customer#000000097 2184.48
+Customer#000000121 6448.32
+Customer#000000133 2334.67
+update customer set c_acctbal = c_acctbal-20 where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation where
+n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between "1992-01-09" and "1995-01-08");
+c_name c_acctbal
+Customer#000000014 5266.3
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000038 6345.11
+Customer#000000098 -551.37
+Customer#000000113 2912
+Customer#000000008 6819.74
+Customer#000000035 1228.24
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+set optimizer_switch='firstmatch=default';
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+explain format=json
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.382051418,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY"],
+ "loops": 1,
+ "rows": 150,
+ "cost": 0.03493875,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ALL",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "loops": 1,
+ "rows": 1500,
+ "cost": 0.2532975,
+ "filtered": 16.13333321,
+ "attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+explain
+update customer set c_acctbal = c_acctbal+5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders ALL i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where
+explain format=json
+update customer set c_acctbal = c_acctbal+5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.382051418,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY"],
+ "loops": 1,
+ "rows": 150,
+ "cost": 0.03493875,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["o_custkey"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "ALL",
+ "possible_keys": ["i_o_orderdate", "i_o_custkey"],
+ "loops": 1,
+ "rows": 1500,
+ "cost": 0.2532975,
+ "filtered": 16.13333321,
+ "attached_condition": "orders.o_orderDATE between '1992-01-09' and '1993-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+update customer set c_acctbal = c_acctbal+5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 716.56
+Customer#000000002 126.65
+Customer#000000005 799.47
+Customer#000000007 9566.95
+Customer#000000008 6824.74
+Customer#000000010 2758.54
+Customer#000000011 -267.6
+Customer#000000013 3862.34
+Customer#000000014 5271.3
+Customer#000000016 4686.03
+Customer#000000017 11.34
+Customer#000000019 8919.71
+Customer#000000022 596.98
+Customer#000000023 3337.02
+Customer#000000025 7138.7
+Customer#000000028 1012.18
+Customer#000000029 7623.27
+Customer#000000031 5241.89
+Customer#000000032 3476.53
+Customer#000000034 8594.7
+Customer#000000035 1233.24
+Customer#000000037 -912.75
+Customer#000000038 6350.11
+Customer#000000040 1340.3
+Customer#000000041 275.95
+Customer#000000043 9909.28
+Customer#000000044 7320.94
+Customer#000000046 5749.59
+Customer#000000047 279.58
+Customer#000000049 4578.94
+Customer#000000052 5635.28
+Customer#000000053 4118.64
+Customer#000000055 4577.11
+Customer#000000056 6535.86
+Customer#000000058 6483.46
+Customer#000000059 3463.6
+Customer#000000061 1541.24
+Customer#000000062 600.61
+Customer#000000064 -641.64
+Customer#000000065 8800.16
+Customer#000000067 8171.59
+Customer#000000070 4872.52
+Customer#000000071 -606.19
+Customer#000000073 4293.5
+Customer#000000074 2769.43
+Customer#000000076 5750.33
+Customer#000000079 5126.28
+Customer#000000080 7388.53
+Customer#000000082 9473.34
+Customer#000000083 6468.51
+Customer#000000085 3391.64
+Customer#000000086 3311.32
+Customer#000000088 8036.44
+Customer#000000089 1535.76
+Customer#000000091 4648.14
+Customer#000000092 1187.91
+Customer#000000094 5505.11
+Customer#000000095 5332.38
+Customer#000000097 2169.48
+Customer#000000098 -546.37
+Customer#000000100 9894.89
+Customer#000000101 7475.96
+Customer#000000103 2762.45
+Customer#000000104 -583.38
+Customer#000000106 3293.42
+Customer#000000107 2519.15
+Customer#000000109 -711.1
+Customer#000000110 7467.99
+Customer#000000112 2958.35
+Customer#000000115 7513.92
+Customer#000000116 8408.99
+Customer#000000118 3587.37
+Customer#000000121 6433.32
+Customer#000000122 7870.46
+Customer#000000127 9285.71
+Customer#000000128 -981.96
+Customer#000000130 5078.58
+Customer#000000131 8600.53
+Customer#000000133 2319.67
+Customer#000000134 4613.9
+Customer#000000136 -837.39
+Customer#000000137 7843.3
+Customer#000000139 7902.78
+Customer#000000140 9968.15
+Customer#000000142 2214.81
+Customer#000000143 2191.5
+Customer#000000145 9753.93
+Customer#000000148 2140.6
+Customer#000000149 8964.65
+update customer set c_acctbal = c_acctbal-5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 114 Using index condition; Using where
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000034 8589.7
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+explain
+update customer set c_acctbal = c_acctbal+1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED orders range i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 114 Using index condition; Using where
+update customer set c_acctbal = c_acctbal+1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+Customer#000000001 712.56
+Customer#000000002 122.65
+Customer#000000007 9562.95
+Customer#000000008 6820.74
+Customer#000000010 2754.54
+Customer#000000011 -271.6
+Customer#000000016 4682.03
+Customer#000000017 7.34
+Customer#000000019 8915.71
+Customer#000000022 592.98
+Customer#000000023 3333.02
+Customer#000000025 7134.7
+Customer#000000028 1008.18
+Customer#000000029 7619.27
+Customer#000000031 5237.89
+Customer#000000034 8590.7
+Customer#000000037 -916.75
+Customer#000000040 1336.3
+Customer#000000043 9905.28
+Customer#000000044 7316.94
+Customer#000000046 5745.59
+Customer#000000047 275.58
+Customer#000000049 4574.94
+Customer#000000053 4114.64
+Customer#000000055 4573.11
+Customer#000000061 1537.24
+Customer#000000064 -645.64
+Customer#000000067 8167.59
+Customer#000000070 4868.52
+Customer#000000071 -610.19
+Customer#000000073 4289.5
+Customer#000000074 2765.43
+Customer#000000076 5746.33
+Customer#000000079 5122.28
+Customer#000000080 7384.53
+Customer#000000082 9469.34
+Customer#000000083 6464.51
+Customer#000000085 3387.64
+Customer#000000086 3307.32
+Customer#000000088 8032.44
+Customer#000000091 4644.14
+Customer#000000092 1183.91
+Customer#000000095 5328.38
+Customer#000000097 2165.48
+Customer#000000100 9890.89
+Customer#000000101 7471.96
+Customer#000000103 2758.45
+Customer#000000104 -587.38
+Customer#000000106 3289.42
+Customer#000000109 -715.1
+Customer#000000110 7463.99
+Customer#000000112 2954.35
+Customer#000000118 3583.37
+Customer#000000121 6429.32
+Customer#000000122 7866.46
+Customer#000000127 9281.71
+Customer#000000130 5074.58
+Customer#000000131 8596.53
+Customer#000000133 2315.67
+Customer#000000134 4609.9
+Customer#000000136 -841.39
+Customer#000000137 7839.3
+Customer#000000139 7898.78
+Customer#000000142 2210.81
+Customer#000000143 2187.5
+Customer#000000148 2136.6
+Customer#000000149 8960.65
+update customer set c_acctbal = c_acctbal-1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-06-09' and '1993-01-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.18
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000034 8589.7
+Customer#000000037 -917.75
+Customer#000000040 1335.3
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000061 1536.24
+Customer#000000064 -646.64
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+# Materialization SJM
+# ===================
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 28
+1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 <subquery2>.o_custkey 1
+2 MATERIALIZED orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
+explain format=json
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.085533248,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "ALL",
+ "possible_keys": ["distinct_key"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.03691572,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "cost": 0.053826401,
+ "having_condition": "count(orders.o_custkey) > 1",
+ "temporary_table": {
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["i_o_orderdate"],
+ "key": "i_o_orderdate",
+ "key_length": "4",
+ "used_key_parts": ["o_orderDATE"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.035889016,
+ "filtered": 100,
+ "index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["c_custkey"],
+ "ref": ["<subquery2>.o_custkey"],
+ "loops": 28,
+ "rows": 1,
+ "cost": 0.048617528,
+ "filtered": 100
+ }
+ }
+ ]
+ }
+}
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+explain
+update customer set c_acctbal = c_acctbal-5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 28
+1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 <subquery2>.o_custkey 1
+2 MATERIALIZED orders range i_o_orderdate i_o_orderdate 4 NULL 28 Using index condition; Using temporary
+explain format=json
+update customer set c_acctbal = c_acctbal-5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.085533248,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "ALL",
+ "possible_keys": ["distinct_key"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.03691572,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "cost": 0.053826401,
+ "having_condition": "count(orders.o_custkey) > 1",
+ "temporary_table": {
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["i_o_orderdate"],
+ "key": "i_o_orderdate",
+ "key_length": "4",
+ "used_key_parts": ["o_orderDATE"],
+ "loops": 1,
+ "rows": 28,
+ "cost": 0.035889016,
+ "filtered": 100,
+ "index_condition": "orders.o_orderDATE between '1992-01-09' and '1992-03-08'"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ {
+ "table": {
+ "table_name": "customer",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["c_custkey"],
+ "ref": ["<subquery2>.o_custkey"],
+ "loops": 28,
+ "rows": 1,
+ "cost": 0.048617528,
+ "filtered": 100
+ }
+ }
+ ]
+ }
+}
+update customer set c_acctbal = c_acctbal-5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3852.34
+Customer#000000032 3466.53
+Customer#000000037 -922.75
+Customer#000000118 3577.37
+Customer#000000056 6525.86
+update customer set c_acctbal = c_acctbal+5 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+explain
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
+2 MATERIALIZED orders ALL i_o_orderdate NULL NULL NULL 1500 Using where; Using temporary
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000016 4681.03
+Customer#000000037 -917.75
+Customer#000000046 5744.59
+Customer#000000091 4643.14
+Customer#000000103 2757.45
+Customer#000000118 3582.37
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+explain
+update customer set c_acctbal = c_acctbal-1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer ALL PRIMARY NULL NULL NULL 150
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 dbt3_s001.customer.c_custkey 1
+2 MATERIALIZED orders ALL i_o_orderdate NULL NULL NULL 1500 Using where; Using temporary
+update customer set c_acctbal = c_acctbal-1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+Customer#000000007 9560.95
+Customer#000000016 4680.03
+Customer#000000037 -918.75
+Customer#000000046 5743.59
+Customer#000000091 4642.14
+Customer#000000103 2756.45
+Customer#000000118 3581.37
+Customer#000000133 2313.67
+Customer#000000134 4607.9
+update customer set c_acctbal = c_acctbal+1 where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+c_name c_acctbal
+Customer#000000007 9561.95
+Customer#000000016 4681.03
+Customer#000000037 -917.75
+Customer#000000046 5744.59
+Customer#000000091 4643.14
+Customer#000000103 2757.45
+Customer#000000118 3582.37
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+# Pullout PS
+# ==========
+prepare stmt from "
+update orders set o_totalprice = o_totalprice+? where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+";
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+set @a1=-20;
+execute stmt using @a1;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201248.06
+2880 145741.99
+3142 16010.15
+5382 138403.03
+5095 184563.99
+737 12964.85
+1729 12117.76
+5121 150314.57
+set @a2=-10;
+execute stmt using @a2;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201238.06
+2880 145731.99
+3142 16000.15
+5382 138393.03
+5095 184553.99
+737 12954.85
+1729 12107.76
+5121 150304.57
+execute stmt using -(@a1+@a2);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+deallocate prepare stmt;
+# FirstMatch PS
+# =============
+set optimizer_switch='materialization=off';
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+";
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.18
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+set @a1=15;
+execute stmt using @a1;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3473.6
+Customer#000000106 3303.42
+Customer#000000017 21.34
+Customer#000000047 289.58
+Customer#000000092 1197.91
+Customer#000000101 7485.96
+Customer#000000022 606.98
+Customer#000000040 1350.3
+Customer#000000064 -631.64
+Customer#000000122 7880.46
+Customer#000000028 1022.18
+Customer#000000037 -902.75
+Customer#000000091 4658.14
+Customer#000000115 7523.92
+Customer#000000067 8181.59
+Customer#000000094 5515.11
+Customer#000000103 2772.45
+Customer#000000130 5088.58
+Customer#000000139 7912.78
+Customer#000000142 2224.81
+Customer#000000025 7148.7
+Customer#000000008 6834.74
+Customer#000000061 1551.24
+Customer#000000077 1753.87
+Customer#000000097 2179.48
+Customer#000000121 6443.32
+Customer#000000133 2329.67
+Customer#000000007 9576.95
+Customer#000000019 8929.71
+Customer#000000082 9483.34
+Customer#000000124 1857.49
+Customer#000000127 9295.71
+set @a2=5;
+execute stmt using @a2;
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3478.6
+Customer#000000106 3308.42
+Customer#000000017 26.34
+Customer#000000047 294.58
+Customer#000000092 1202.91
+Customer#000000101 7490.96
+Customer#000000022 611.98
+Customer#000000040 1355.3
+Customer#000000064 -626.64
+Customer#000000122 7885.46
+Customer#000000028 1027.1799999999998
+Customer#000000037 -897.75
+Customer#000000091 4663.14
+Customer#000000115 7528.92
+Customer#000000067 8186.59
+Customer#000000094 5520.11
+Customer#000000103 2777.45
+Customer#000000130 5093.58
+Customer#000000139 7917.78
+Customer#000000142 2229.81
+Customer#000000025 7153.7
+Customer#000000008 6839.74
+Customer#000000061 1556.24
+Customer#000000077 1758.87
+Customer#000000097 2184.48
+Customer#000000121 6448.32
+Customer#000000133 2334.67
+Customer#000000007 9581.95
+Customer#000000019 8934.71
+Customer#000000082 9488.34
+Customer#000000124 1862.49
+Customer#000000127 9300.71
+execute stmt using -(@a1+@a2);
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.1799999999998
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+deallocate prepare stmt;
+set optimizer_switch='materialization=default';
+# Materialization PS
+# ==================
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+";
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.1799999999998
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+set @a1=7;
+execute stmt using @a1;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 718.56
+Customer#000000002 128.65
+Customer#000000005 801.47
+Customer#000000007 9568.95
+Customer#000000008 6826.74
+Customer#000000010 2760.54
+Customer#000000011 -265.6
+Customer#000000013 3864.34
+Customer#000000014 5273.3
+Customer#000000016 4688.03
+Customer#000000017 13.34
+Customer#000000019 8921.71
+Customer#000000022 598.98
+Customer#000000023 3339.02
+Customer#000000025 7140.7
+Customer#000000028 1014.1799999999998
+Customer#000000029 7625.27
+Customer#000000031 5243.89
+Customer#000000032 3478.53
+Customer#000000034 8596.7
+Customer#000000035 1235.24
+Customer#000000037 -910.75
+Customer#000000038 6352.11
+Customer#000000040 1342.3
+Customer#000000041 277.95
+Customer#000000043 9911.28
+Customer#000000044 7322.94
+Customer#000000046 5751.59
+Customer#000000047 281.58
+Customer#000000049 4580.94
+Customer#000000052 5637.28
+Customer#000000053 4120.64
+Customer#000000055 4579.11
+Customer#000000056 6537.86
+Customer#000000058 6485.46
+Customer#000000059 3465.6
+Customer#000000061 1543.24
+Customer#000000062 602.61
+Customer#000000064 -639.64
+Customer#000000065 8802.16
+Customer#000000067 8173.59
+Customer#000000070 4874.52
+Customer#000000071 -604.19
+Customer#000000073 4295.5
+Customer#000000074 2771.43
+Customer#000000076 5752.33
+Customer#000000079 5128.28
+Customer#000000080 7390.53
+Customer#000000082 9475.34
+Customer#000000083 6470.51
+Customer#000000085 3393.64
+Customer#000000086 3313.32
+Customer#000000088 8038.44
+Customer#000000089 1537.76
+Customer#000000091 4650.14
+Customer#000000092 1189.91
+Customer#000000094 5507.11
+Customer#000000095 5334.38
+Customer#000000097 2171.48
+Customer#000000098 -544.37
+Customer#000000100 9896.89
+Customer#000000101 7477.96
+Customer#000000103 2764.45
+Customer#000000104 -581.38
+Customer#000000106 3295.42
+Customer#000000107 2521.15
+Customer#000000109 -709.1
+Customer#000000110 7469.99
+Customer#000000112 2960.35
+Customer#000000115 7515.92
+Customer#000000116 8410.99
+Customer#000000118 3589.37
+Customer#000000121 6435.32
+Customer#000000122 7872.46
+Customer#000000127 9287.71
+Customer#000000128 -979.96
+Customer#000000130 5080.58
+Customer#000000131 8602.53
+Customer#000000133 2321.67
+Customer#000000134 4615.9
+Customer#000000136 -835.39
+Customer#000000137 7845.3
+Customer#000000139 7904.78
+Customer#000000140 9970.15
+Customer#000000142 2216.81
+Customer#000000143 2193.5
+Customer#000000145 9755.93
+Customer#000000148 2142.6
+Customer#000000149 8966.65
+set @a2=3;
+execute stmt using @a2;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 721.56
+Customer#000000002 131.65
+Customer#000000005 804.47
+Customer#000000007 9571.95
+Customer#000000008 6829.74
+Customer#000000010 2763.54
+Customer#000000011 -262.6
+Customer#000000013 3867.34
+Customer#000000014 5276.3
+Customer#000000016 4691.03
+Customer#000000017 16.34
+Customer#000000019 8924.71
+Customer#000000022 601.98
+Customer#000000023 3342.02
+Customer#000000025 7143.7
+Customer#000000028 1017.1799999999998
+Customer#000000029 7628.27
+Customer#000000031 5246.89
+Customer#000000032 3481.53
+Customer#000000034 8599.7
+Customer#000000035 1238.24
+Customer#000000037 -907.75
+Customer#000000038 6355.11
+Customer#000000040 1345.3
+Customer#000000041 280.95
+Customer#000000043 9914.28
+Customer#000000044 7325.94
+Customer#000000046 5754.59
+Customer#000000047 284.58
+Customer#000000049 4583.94
+Customer#000000052 5640.28
+Customer#000000053 4123.64
+Customer#000000055 4582.11
+Customer#000000056 6540.86
+Customer#000000058 6488.46
+Customer#000000059 3468.6
+Customer#000000061 1546.24
+Customer#000000062 605.61
+Customer#000000064 -636.64
+Customer#000000065 8805.16
+Customer#000000067 8176.59
+Customer#000000070 4877.52
+Customer#000000071 -601.19
+Customer#000000073 4298.5
+Customer#000000074 2774.43
+Customer#000000076 5755.33
+Customer#000000079 5131.28
+Customer#000000080 7393.53
+Customer#000000082 9478.34
+Customer#000000083 6473.51
+Customer#000000085 3396.64
+Customer#000000086 3316.32
+Customer#000000088 8041.44
+Customer#000000089 1540.76
+Customer#000000091 4653.14
+Customer#000000092 1192.91
+Customer#000000094 5510.11
+Customer#000000095 5337.38
+Customer#000000097 2174.48
+Customer#000000098 -541.37
+Customer#000000100 9899.89
+Customer#000000101 7480.96
+Customer#000000103 2767.45
+Customer#000000104 -578.38
+Customer#000000106 3298.42
+Customer#000000107 2524.15
+Customer#000000109 -706.1
+Customer#000000110 7472.99
+Customer#000000112 2963.35
+Customer#000000115 7518.92
+Customer#000000116 8413.99
+Customer#000000118 3592.37
+Customer#000000121 6438.32
+Customer#000000122 7875.46
+Customer#000000127 9290.71
+Customer#000000128 -976.96
+Customer#000000130 5083.58
+Customer#000000131 8605.53
+Customer#000000133 2324.67
+Customer#000000134 4618.9
+Customer#000000136 -832.39
+Customer#000000137 7848.3
+Customer#000000139 7907.78
+Customer#000000140 9973.15
+Customer#000000142 2219.81
+Customer#000000143 2196.5
+Customer#000000145 9758.93
+Customer#000000148 2145.6
+Customer#000000149 8969.65
+execute stmt using -(@a1+@a2);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.1799999999998
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+deallocate prepare stmt;
+# Materialization SJM PS
+# ======================
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+";
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+set @a1=-2;
+execute stmt using @a1;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3855.34
+Customer#000000032 3469.53
+Customer#000000037 -919.75
+Customer#000000118 3580.37
+Customer#000000056 6528.86
+set @a2=-1;
+execute stmt using @a2;
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3854.34
+Customer#000000032 3468.53
+Customer#000000037 -920.75
+Customer#000000118 3579.37
+Customer#000000056 6527.86
+execute stmt using -(@a1+@a2);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+deallocate prepare stmt;
+# Pullout SP
+# ==========
+create procedure p(d int)
+update orders set o_totalprice = o_totalprice+d where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+call p(-10);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201258.06
+2880 145751.99
+3142 16020.15
+5382 138413.03
+5095 184573.99
+737 12974.85
+1729 12127.76
+5121 150324.57
+call p(-20);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201238.06
+2880 145731.99
+3142 16000.15
+5382 138393.03
+5095 184553.99
+737 12954.85
+1729 12107.76
+5121 150304.57
+call p(10+20);
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (select n_nationkey from nation
+where n_name='PERU'));
+o_orderkey o_totalprice
+644 201268.06
+2880 145761.99
+3142 16030.15
+5382 138423.03
+5095 184583.99
+737 12984.85
+1729 12137.76
+5121 150334.57
+drop procedure p;
+# FirstMatch SP
+# =============
+set optimizer_switch='materialization=off';
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.1799999999998
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+call p(5);
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3463.6
+Customer#000000106 3293.42
+Customer#000000017 11.34
+Customer#000000047 279.58
+Customer#000000092 1187.91
+Customer#000000101 7475.96
+Customer#000000022 596.98
+Customer#000000040 1340.3
+Customer#000000064 -641.64
+Customer#000000122 7870.46
+Customer#000000028 1012.1799999999998
+Customer#000000037 -912.75
+Customer#000000091 4648.14
+Customer#000000115 7513.92
+Customer#000000067 8171.59
+Customer#000000094 5505.11
+Customer#000000103 2762.45
+Customer#000000130 5078.58
+Customer#000000139 7902.78
+Customer#000000142 2214.81
+Customer#000000025 7138.7
+Customer#000000008 6824.74
+Customer#000000061 1541.24
+Customer#000000077 1743.87
+Customer#000000097 2169.48
+Customer#000000121 6433.32
+Customer#000000133 2319.67
+Customer#000000007 9566.95
+Customer#000000019 8919.71
+Customer#000000082 9473.34
+Customer#000000124 1847.49
+Customer#000000127 9285.71
+call p(15);
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3478.6
+Customer#000000106 3308.42
+Customer#000000017 26.34
+Customer#000000047 294.58
+Customer#000000092 1202.91
+Customer#000000101 7490.96
+Customer#000000022 611.98
+Customer#000000040 1355.3
+Customer#000000064 -626.64
+Customer#000000122 7885.46
+Customer#000000028 1027.1799999999998
+Customer#000000037 -897.75
+Customer#000000091 4663.14
+Customer#000000115 7528.92
+Customer#000000067 8186.59
+Customer#000000094 5520.11
+Customer#000000103 2777.45
+Customer#000000130 5093.58
+Customer#000000139 7917.78
+Customer#000000142 2229.81
+Customer#000000025 7153.7
+Customer#000000008 6839.74
+Customer#000000061 1556.24
+Customer#000000077 1758.87
+Customer#000000097 2184.48
+Customer#000000121 6448.32
+Customer#000000133 2334.67
+Customer#000000007 9581.95
+Customer#000000019 8934.71
+Customer#000000082 9488.34
+Customer#000000124 1862.49
+Customer#000000127 9300.71
+call p(-(5+15));
+select c_name, c_acctbal from customer where c_nationkey in (select n_nationkey from nation
+where n_regionkey in (1,2))
+and
+c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-10-09' and '1993-06-08');
+c_name c_acctbal
+Customer#000000059 3458.6
+Customer#000000106 3288.42
+Customer#000000017 6.34
+Customer#000000047 274.58
+Customer#000000092 1182.91
+Customer#000000101 7470.96
+Customer#000000022 591.98
+Customer#000000040 1335.3
+Customer#000000064 -646.64
+Customer#000000122 7865.46
+Customer#000000028 1007.1799999999998
+Customer#000000037 -917.75
+Customer#000000091 4643.14
+Customer#000000115 7508.92
+Customer#000000067 8166.59
+Customer#000000094 5500.11
+Customer#000000103 2757.45
+Customer#000000130 5073.58
+Customer#000000139 7897.78
+Customer#000000142 2209.81
+Customer#000000025 7133.7
+Customer#000000008 6819.74
+Customer#000000061 1536.24
+Customer#000000077 1738.87
+Customer#000000097 2164.48
+Customer#000000121 6428.32
+Customer#000000133 2314.67
+Customer#000000007 9561.95
+Customer#000000019 8914.71
+Customer#000000082 9468.34
+Customer#000000124 1842.49
+Customer#000000127 9280.71
+drop procedure p;
+set optimizer_switch='materialization=default';
+# Materialization SP
+# ==================
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.1799999999998
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+call p(3);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 714.56
+Customer#000000002 124.65
+Customer#000000005 797.47
+Customer#000000007 9564.95
+Customer#000000008 6822.74
+Customer#000000010 2756.54
+Customer#000000011 -269.6
+Customer#000000013 3860.34
+Customer#000000014 5269.3
+Customer#000000016 4684.03
+Customer#000000017 9.34
+Customer#000000019 8917.71
+Customer#000000022 594.98
+Customer#000000023 3335.02
+Customer#000000025 7136.7
+Customer#000000028 1010.1799999999998
+Customer#000000029 7621.27
+Customer#000000031 5239.89
+Customer#000000032 3474.53
+Customer#000000034 8592.7
+Customer#000000035 1231.24
+Customer#000000037 -914.75
+Customer#000000038 6348.11
+Customer#000000040 1338.3
+Customer#000000041 273.95
+Customer#000000043 9907.28
+Customer#000000044 7318.94
+Customer#000000046 5747.59
+Customer#000000047 277.58
+Customer#000000049 4576.94
+Customer#000000052 5633.28
+Customer#000000053 4116.64
+Customer#000000055 4575.11
+Customer#000000056 6533.86
+Customer#000000058 6481.46
+Customer#000000059 3461.6
+Customer#000000061 1539.24
+Customer#000000062 598.61
+Customer#000000064 -643.64
+Customer#000000065 8798.16
+Customer#000000067 8169.59
+Customer#000000070 4870.52
+Customer#000000071 -608.19
+Customer#000000073 4291.5
+Customer#000000074 2767.43
+Customer#000000076 5748.33
+Customer#000000079 5124.28
+Customer#000000080 7386.53
+Customer#000000082 9471.34
+Customer#000000083 6466.51
+Customer#000000085 3389.64
+Customer#000000086 3309.32
+Customer#000000088 8034.44
+Customer#000000089 1533.76
+Customer#000000091 4646.14
+Customer#000000092 1185.91
+Customer#000000094 5503.11
+Customer#000000095 5330.38
+Customer#000000097 2167.48
+Customer#000000098 -548.37
+Customer#000000100 9892.89
+Customer#000000101 7473.96
+Customer#000000103 2760.45
+Customer#000000104 -585.38
+Customer#000000106 3291.42
+Customer#000000107 2517.15
+Customer#000000109 -713.1
+Customer#000000110 7465.99
+Customer#000000112 2956.35
+Customer#000000115 7511.92
+Customer#000000116 8406.99
+Customer#000000118 3585.37
+Customer#000000121 6431.32
+Customer#000000122 7868.46
+Customer#000000127 9283.71
+Customer#000000128 -983.96
+Customer#000000130 5076.58
+Customer#000000131 8598.53
+Customer#000000133 2317.67
+Customer#000000134 4611.9
+Customer#000000136 -839.39
+Customer#000000137 7841.3
+Customer#000000139 7900.78
+Customer#000000140 9966.15
+Customer#000000142 2212.81
+Customer#000000143 2189.5
+Customer#000000145 9751.93
+Customer#000000148 2138.6
+Customer#000000149 8962.65
+call p(7);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 721.56
+Customer#000000002 131.65
+Customer#000000005 804.47
+Customer#000000007 9571.95
+Customer#000000008 6829.74
+Customer#000000010 2763.54
+Customer#000000011 -262.6
+Customer#000000013 3867.34
+Customer#000000014 5276.3
+Customer#000000016 4691.03
+Customer#000000017 16.34
+Customer#000000019 8924.71
+Customer#000000022 601.98
+Customer#000000023 3342.02
+Customer#000000025 7143.7
+Customer#000000028 1017.1799999999998
+Customer#000000029 7628.27
+Customer#000000031 5246.89
+Customer#000000032 3481.53
+Customer#000000034 8599.7
+Customer#000000035 1238.24
+Customer#000000037 -907.75
+Customer#000000038 6355.11
+Customer#000000040 1345.3
+Customer#000000041 280.95
+Customer#000000043 9914.28
+Customer#000000044 7325.94
+Customer#000000046 5754.59
+Customer#000000047 284.58
+Customer#000000049 4583.94
+Customer#000000052 5640.28
+Customer#000000053 4123.64
+Customer#000000055 4582.11
+Customer#000000056 6540.86
+Customer#000000058 6488.46
+Customer#000000059 3468.6
+Customer#000000061 1546.24
+Customer#000000062 605.61
+Customer#000000064 -636.64
+Customer#000000065 8805.16
+Customer#000000067 8176.59
+Customer#000000070 4877.52
+Customer#000000071 -601.19
+Customer#000000073 4298.5
+Customer#000000074 2774.43
+Customer#000000076 5755.33
+Customer#000000079 5131.28
+Customer#000000080 7393.53
+Customer#000000082 9478.34
+Customer#000000083 6473.51
+Customer#000000085 3396.64
+Customer#000000086 3316.32
+Customer#000000088 8041.44
+Customer#000000089 1540.76
+Customer#000000091 4653.14
+Customer#000000092 1192.91
+Customer#000000094 5510.11
+Customer#000000095 5337.38
+Customer#000000097 2174.48
+Customer#000000098 -541.37
+Customer#000000100 9899.89
+Customer#000000101 7480.96
+Customer#000000103 2767.45
+Customer#000000104 -578.38
+Customer#000000106 3298.42
+Customer#000000107 2524.15
+Customer#000000109 -706.1
+Customer#000000110 7472.99
+Customer#000000112 2963.35
+Customer#000000115 7518.92
+Customer#000000116 8413.99
+Customer#000000118 3592.37
+Customer#000000121 6438.32
+Customer#000000122 7875.46
+Customer#000000127 9290.71
+Customer#000000128 -976.96
+Customer#000000130 5083.58
+Customer#000000131 8605.53
+Customer#000000133 2324.67
+Customer#000000134 4618.9
+Customer#000000136 -832.39
+Customer#000000137 7848.3
+Customer#000000139 7907.78
+Customer#000000140 9973.15
+Customer#000000142 2219.81
+Customer#000000143 2196.5
+Customer#000000145 9758.93
+Customer#000000148 2145.6
+Customer#000000149 8969.65
+call p(-(3+7));
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1993-03-08');
+c_name c_acctbal
+Customer#000000001 711.56
+Customer#000000002 121.65
+Customer#000000005 794.47
+Customer#000000007 9561.95
+Customer#000000008 6819.74
+Customer#000000010 2753.54
+Customer#000000011 -272.6
+Customer#000000013 3857.34
+Customer#000000014 5266.3
+Customer#000000016 4681.03
+Customer#000000017 6.34
+Customer#000000019 8914.71
+Customer#000000022 591.98
+Customer#000000023 3332.02
+Customer#000000025 7133.7
+Customer#000000028 1007.1799999999998
+Customer#000000029 7618.27
+Customer#000000031 5236.89
+Customer#000000032 3471.53
+Customer#000000034 8589.7
+Customer#000000035 1228.24
+Customer#000000037 -917.75
+Customer#000000038 6345.11
+Customer#000000040 1335.3
+Customer#000000041 270.95
+Customer#000000043 9904.28
+Customer#000000044 7315.94
+Customer#000000046 5744.59
+Customer#000000047 274.58
+Customer#000000049 4573.94
+Customer#000000052 5630.28
+Customer#000000053 4113.64
+Customer#000000055 4572.11
+Customer#000000056 6530.86
+Customer#000000058 6478.46
+Customer#000000059 3458.6
+Customer#000000061 1536.24
+Customer#000000062 595.61
+Customer#000000064 -646.64
+Customer#000000065 8795.16
+Customer#000000067 8166.59
+Customer#000000070 4867.52
+Customer#000000071 -611.19
+Customer#000000073 4288.5
+Customer#000000074 2764.43
+Customer#000000076 5745.33
+Customer#000000079 5121.28
+Customer#000000080 7383.53
+Customer#000000082 9468.34
+Customer#000000083 6463.51
+Customer#000000085 3386.64
+Customer#000000086 3306.32
+Customer#000000088 8031.44
+Customer#000000089 1530.76
+Customer#000000091 4643.14
+Customer#000000092 1182.91
+Customer#000000094 5500.11
+Customer#000000095 5327.38
+Customer#000000097 2164.48
+Customer#000000098 -551.37
+Customer#000000100 9889.89
+Customer#000000101 7470.96
+Customer#000000103 2757.45
+Customer#000000104 -588.38
+Customer#000000106 3288.42
+Customer#000000107 2514.15
+Customer#000000109 -716.1
+Customer#000000110 7462.99
+Customer#000000112 2953.35
+Customer#000000115 7508.92
+Customer#000000116 8403.99
+Customer#000000118 3582.37
+Customer#000000121 6428.32
+Customer#000000122 7865.46
+Customer#000000127 9280.71
+Customer#000000128 -986.96
+Customer#000000130 5073.58
+Customer#000000131 8595.53
+Customer#000000133 2314.67
+Customer#000000134 4608.9
+Customer#000000136 -842.39
+Customer#000000137 7838.3
+Customer#000000139 7897.78
+Customer#000000140 9963.15
+Customer#000000142 2209.81
+Customer#000000143 2186.5
+Customer#000000145 9748.93
+Customer#000000148 2135.6
+Customer#000000149 8959.65
+drop procedure p;
+# Materialization SJM SP
+# ======================
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+call p(-1);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3856.34
+Customer#000000032 3470.53
+Customer#000000037 -918.75
+Customer#000000118 3581.37
+Customer#000000056 6529.86
+call p(-2);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3854.34
+Customer#000000032 3468.53
+Customer#000000037 -920.75
+Customer#000000118 3579.37
+Customer#000000056 6527.86
+call p(1+2);
+select c_name, c_acctbal from customer where c_custkey in (select o_custkey from orders
+where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+c_name c_acctbal
+Customer#000000013 3857.34
+Customer#000000032 3471.53
+Customer#000000037 -917.75
+Customer#000000118 3582.37
+Customer#000000056 6530.86
+drop procedure p;
+# Checking limitations
+# ====================
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+324 26868.85
+1856 189361.42
+1344 43809.37
+1925 146382.71
+3139 40975.96
+4903 34363.63
+5607 24660.06
+# Should not use semi-join conversion because has ORDER BY ... LIMIT
+explain
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2))
+order by o_totalprice limit 500;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY orders range i_o_orderdate i_o_orderdate 4 NULL 108 Using where; Using filesort
+2 DEPENDENT SUBQUERY customer unique_subquery PRIMARY,i_c_nationkey PRIMARY 4 func 1 Using where
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2))
+order by o_totalprice limit 500;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117347.16
+324 26818.85
+1856 189311.42
+1344 43759.37
+1925 146332.71
+3139 40925.96
+4903 34313.63
+5607 24610.06
+update orders set o_totalprice = o_totalprice+50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2))
+order by o_totalprice limit 500;
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+324 26868.85
+1856 189361.42
+1344 43809.37
+1925 146382.71
+3139 40975.96
+4903 34363.63
+5607 24660.06
+# Should use semi-join converion
+explain
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY customer range PRIMARY,i_c_nationkey i_c_nationkey 5 NULL 15 Using index condition
+1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (7%) Using where; Using rowid filter
+update orders set o_totalprice = o_totalprice-50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117347.16
+324 26818.85
+1856 189311.42
+1344 43759.37
+1925 146332.71
+3139 40925.96
+4903 34313.63
+5607 24610.06
+update orders set o_totalprice = o_totalprice+50 where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and
+o_custkey in (select c_custkey from customer
+where c_nationkey in (1,2));
+o_orderkey o_totalprice
+1221 117397.16
+324 26868.85
+1856 189361.42
+1344 43809.37
+1925 146382.71
+3139 40975.96
+4903 34363.63
+5607 24660.06
+CREATE TABLE partsupp_small (
+ps_partkey int(11) NOT NULL DEFAULT '0',
+ps_suppkey int(11) NOT NULL DEFAULT '0',
+ps_availqty int(11) DEFAULT NULL,
+ps_supplycost double DEFAULT NULL,
+ps_comment varchar(199) DEFAULT NULL,
+PRIMARY KEY (ps_partkey,ps_suppkey),
+KEY i_ps_partkey (ps_partkey),
+KEY i_ps_suppkey (ps_suppkey)
+);
+create index i_ps_sup_part on partsupp_small(ps_suppkey, ps_partkey);
+insert into partsupp_small select * from partsupp where ps_partkey <50;
+analyze table partsupp_small persistent for all;
+Table Op Msg_type Msg_text
+dbt3_s001.partsupp_small analyze status Engine-independent statistics collected
+dbt3_s001.partsupp_small analyze status OK
+# LooseScan
+# =========
+explain
+select count(*) from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY partsupp_small index PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 8 NULL 176 Using where; Using index; LooseScan
+1 PRIMARY lineitem ref i_l_suppkey i_l_suppkey 5 dbt3_s001.partsupp_small.ps_suppkey 600 Using index
+explain format=json
+select count(*) from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.776623555,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "index",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "8",
+ "used_key_parts": ["ps_suppkey", "ps_partkey"],
+ "loops": 1,
+ "rows": 176,
+ "cost": 0.019403477,
+ "filtered": 5.113636494,
+ "attached_condition": "partsupp_small.ps_partkey in (1,2,3)",
+ "using_index": true,
+ "loose_scan": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey"],
+ "key": "i_l_suppkey",
+ "key_length": "5",
+ "used_key_parts": ["l_suppkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_suppkey"],
+ "loops": 9,
+ "rows": 600,
+ "cost": 0.757220078,
+ "filtered": 11.11111069,
+ "using_index": true
+ }
+ }
+ ]
+ }
+}
+select count(*) from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+count(*)
+5373
+select 5373 as count, 136458704.22 as old_sum;
+count old_sum
+5373 136458704.22
+explain
+update lineitem set l_extendedprice=l_extendedprice+10 where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY lineitem ALL i_l_suppkey NULL NULL NULL 6005
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED partsupp_small range PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part PRIMARY 4 NULL 9 Using where; Using index
+explain format=json
+update lineitem set l_extendedprice=l_extendedprice+10 where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 2.191459679,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ALL",
+ "possible_keys": ["i_l_suppkey"],
+ "loops": 1,
+ "rows": 6005,
+ "cost": 0.988432825,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["ps_partkey"],
+ "loops": 1,
+ "rows": 9,
+ "cost": 0.003756598,
+ "filtered": 100,
+ "attached_condition": "partsupp_small.ps_partkey in (1,2,3)",
+ "using_index": true
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+update lineitem set l_extendedprice=l_extendedprice+10 where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+(136458704.22+10*5373) as 'old_sum+10*count'
+ from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum+10*count
+136512434.22 5373 136512434.22
+update lineitem set l_extendedprice=l_extendedprice-10 where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+136458704.22 as old_sum from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum
+136458704.22 5373 136458704.22
+# LooseScan PS
+# ============
+prepare stmt from "
+update lineitem set l_extendedprice=l_extendedprice+? where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+";
+select 5373 as count, 136458704.22 as old_sum;
+count old_sum
+5373 136458704.22
+set @a1=20;
+execute stmt using @a1;
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+(136458704.22+20*5373) as 'old_sum+20*count'
+ from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum+20*count
+136566164.22 5373 136566164.22
+set @a2=10;
+execute stmt using @a2;
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+(136458704.22+30*5373) as 'old_sum+30*count'
+ from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum+30*count
+136619894.22 5373 136619894.22
+execute stmt using -(@a1+@a2);
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+136458704.22 as old_sum from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum
+136458704.22 5373 136458704.22
+deallocate prepare stmt;
+# LooseScan SP
+# ============
+create procedure p(d int)
+update lineitem set l_extendedprice=l_extendedprice+d where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+select 5373 as count, 136458704.22 as old_sum;
+count old_sum
+5373 136458704.22
+call p(10);
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+(136458704.22+10*5373) as 'old_sum+10*count'
+ from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum+10*count
+136512434.22 5373 136512434.22
+call p(20);
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+(136458704.22+30*5373) as 'old_sum+30*count'
+ from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum+30*count
+136619894.22 5373 136619894.22
+call p(-(10+20));
+select ROUND(sum(l_extendedprice),2), 5373 as count,
+136458704.22 as old_sum from lineitem where l_suppkey in
+(select ps_suppkey from partsupp_small
+where ps_partkey in (1,2,3));
+ROUND(sum(l_extendedprice),2) count old_sum
+136458704.22 5373 136458704.22
+drop procedure p;
+# DuplicateWeedout
+# ================
+set @tmp_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='materialization=off';
+analyze table lineitem;
+Table Op Msg_type Msg_text
+dbt3_s001.lineitem analyze status Engine-independent statistics collected
+dbt3_s001.lineitem analyze status OK
+analyze table orders;
+Table Op Msg_type Msg_text
+dbt3_s001.orders analyze status Engine-independent statistics collected
+dbt3_s001.orders analyze status OK
+explain
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY supplier range PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Start temporary
+1 PRIMARY partsupp_small ref PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 4 dbt3_s001.supplier.s_suppkey 17 Using where; Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index; End temporary
+explain format=json
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 4.129940741,
+ "nested_loop": [
+ {
+ "duplicates_removal": [
+ {
+ "table": {
+ "table_name": "supplier",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["s_suppkey"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.001478954,
+ "filtered": 100,
+ "attached_condition": "supplier.s_suppkey < 2",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["dbt3_s001.supplier.s_suppkey"],
+ "loops": 1,
+ "rows": 17,
+ "cost": 0.003160332,
+ "filtered": 79.54545593,
+ "attached_condition": "partsupp_small.ps_partkey is not null",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_suppkey_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 14,
+ "rows": 30,
+ "cost": 0.069152188,
+ "filtered": 100,
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 420.35,
+ "rows": 30,
+ "cost": 1.994712365,
+ "filtered": 0.237896994,
+ "using_index": true
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+select count(*) from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+count(*)
+471
+select 471 as count, 10751458.66 as old_sum;
+count old_sum
+471 10751458.66
+explain
+update lineitem set l_extendedprice=l_extendedprice+10 where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY supplier range PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Start temporary
+1 PRIMARY partsupp_small ref PRIMARY,i_ps_partkey,i_ps_suppkey,i_ps_sup_part i_ps_sup_part 4 dbt3_s001.supplier.s_suppkey 17 Using where; Using index
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30
+1 PRIMARY lineitem ref i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 dbt3_s001.partsupp_small.ps_partkey 30 Using index; End temporary
+explain format=json
+update lineitem set l_extendedprice=l_extendedprice+10 where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 4.590092321,
+ "nested_loop": [
+ {
+ "duplicates_removal": [
+ {
+ "table": {
+ "table_name": "supplier",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["s_suppkey"],
+ "loops": 1,
+ "rows": 1,
+ "cost": 0.001478954,
+ "filtered": 100,
+ "attached_condition": "supplier.s_suppkey < 2",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "partsupp_small",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_ps_partkey",
+ "i_ps_suppkey",
+ "i_ps_sup_part"
+ ],
+ "key": "i_ps_sup_part",
+ "key_length": "4",
+ "used_key_parts": ["ps_suppkey"],
+ "ref": ["dbt3_s001.supplier.s_suppkey"],
+ "loops": 1,
+ "rows": 17,
+ "cost": 0.003160332,
+ "filtered": 79.54545593,
+ "attached_condition": "partsupp_small.ps_partkey is not null",
+ "using_index": true
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_suppkey_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 14,
+ "rows": 30,
+ "cost": 0.529303768,
+ "filtered": 100
+ }
+ },
+ {
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": ["i_l_suppkey_partkey", "i_l_partkey"],
+ "key": "i_l_partkey",
+ "key_length": "5",
+ "used_key_parts": ["l_partkey"],
+ "ref": ["dbt3_s001.partsupp_small.ps_partkey"],
+ "loops": 420.35,
+ "rows": 30,
+ "cost": 1.994712365,
+ "filtered": 0.237896994,
+ "using_index": true
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+update lineitem set l_extendedprice=l_extendedprice+10 where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+select ROUND(sum(l_extendedprice),2), 471 as count,
+(10751458.66+10*471) as 'old_sum+10*count'
+ from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum+10*count
+10756168.66 471 10756168.66
+update lineitem set l_extendedprice=l_extendedprice-10 where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+select ROUND(sum(l_extendedprice),2), 471 as count,
+10751458.66 as old_sum from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum
+10751458.66 471 10751458.66
+# DuplicateWeedout PS
+# ===================
+prepare stmt from "
+update lineitem set l_extendedprice=l_extendedprice+? where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+";
+select 471 as count, 10751458.66 as old_sum;
+count old_sum
+471 10751458.66
+set @a1=20;
+execute stmt using @a1;
+select ROUND(sum(l_extendedprice),2), 471 as count,
+(10751458.66+20*471) as 'old_sum+20*count'
+ from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum+20*count
+10760878.66 471 10760878.66
+set @a2=10;
+execute stmt using @a2;
+select ROUND(sum(l_extendedprice),2), 471 as count,
+(10751458.66+30*471) as 'old_sum+30*count'
+ from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum+30*count
+10765588.66 471 10765588.66
+execute stmt using -(@a1+@a2);
+select ROUND(sum(l_extendedprice),2), 471 as count,
+10751458.66 as old_sum from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum
+10751458.66 471 10751458.66
+deallocate prepare stmt;
+# DuplicateWeedout SP
+# ===================
+create procedure p(d int)
+update lineitem set l_extendedprice=l_extendedprice+d where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+select 471 as count, 10751458.66 as old_sum;
+count old_sum
+471 10751458.66
+call p(10);
+select ROUND(sum(l_extendedprice),2), 471 as count,
+(10751458.66+10*471) as 'old_sum+10*count'
+ from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum+10*count
+10756168.66 471 10756168.66
+call p(20);
+select ROUND(sum(l_extendedprice),2), 471 as count,
+(10751458.66+30*471) as 'old_sum+30*count'
+ from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum+30*count
+10765588.66 471 10765588.66
+call p(-(10+20));
+select ROUND(sum(l_extendedprice),2), 471 as count,
+10751458.66 as old_sum from lineitem where l_partkey in (
+select ps_partkey
+from partsupp_small join lineitem on ps_partkey=l_partkey
+where ps_suppkey in (
+select s_suppkey from supplier where s_suppkey < 2
+)
+);
+ROUND(sum(l_extendedprice),2) count old_sum
+10751458.66 471 10751458.66
+drop procedure p;
+set @@optimizer_switch=@tmp_optimizer_switch;
+drop table partsupp_small;
+DROP DATABASE dbt3_s001;
diff --git a/mysql-test/main/update_single_to_multi.test b/mysql-test/main/update_single_to_multi.test
new file mode 100644
index 00000000000..7364806e65d
--- /dev/null
+++ b/mysql-test/main/update_single_to_multi.test
@@ -0,0 +1,832 @@
+--disable_warnings
+DROP DATABASE IF EXISTS dbt3_s001;
+--enable_warnings
+
+CREATE DATABASE dbt3_s001;
+
+use dbt3_s001;
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+--source include/dbt3_s001.inc
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+create index i_n_name on nation(n_name);
+analyze table
+ nation, lineitem, customer, orders, part, supplier, partsupp, region
+persistent for all;
+
+--echo # Pullout
+--echo # =======
+
+let $c1=
+ o_orderDATE between '1992-01-01' and '1992-06-30' and
+ o_custkey in (select c_custkey from customer
+ where c_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+explain format=json
+select o_orderkey, o_totalprice from orders where $c1;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+eval
+explain
+update orders set o_totalprice = o_totalprice-50 where $c1;
+eval
+explain format=json
+update orders set o_totalprice = o_totalprice-50 where $c1;
+eval
+update orders set o_totalprice = o_totalprice-50 where $c1;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+eval
+update orders set o_totalprice= o_totalprice+50 where $c1;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+
+let $c2=
+ (ps_partkey, ps_suppkey) in
+ (select p_partkey, s_suppkey from part, supplier
+ where p_retailprice between 901 and 910 and
+ s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+
+eval
+explain
+update partsupp set ps_supplycost = ps_supplycost+2 where $c2;
+eval
+update partsupp set ps_supplycost = ps_supplycost+2 where $c2;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+
+eval
+update partsupp set ps_supplycost = ps_supplycost-2 where $c2;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c2;
+
+
+let $c3=
+ ps_partkey in (select p_partkey from part
+ where p_retailprice between 901 and 910) and
+ ps_suppkey in (select s_suppkey from supplier
+ where s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+eval
+explain
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+
+eval
+explain
+update partsupp set ps_supplycost = ps_supplycost+10 where $c3;
+eval
+update partsupp set ps_supplycost = ps_supplycost+10 where $c3;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+
+eval
+update partsupp set ps_supplycost = ps_supplycost-10 where $c3;
+eval
+select ps_partkey, ps_suppkey, ps_supplycost from partsupp where $c3;
+
+
+let $c4=
+ l_orderkey in (select o_orderkey from orders
+ where o_custkey in
+ (select c_custkey from customer
+ where c_nationkey in
+ (select n_nationkey from nation
+ where n_name='PERU'))
+ and
+ o_orderDATE between '1992-06-30' and '1992-12-31')
+ and
+ (l_partkey, l_suppkey) in
+ (select p_partkey, s_suppkey from part, supplier
+ where p_retailprice between 901 and 1000 and
+ s_nationkey in (select n_nationkey from nation
+ where n_name='PERU'));
+
+eval
+explain
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+
+eval
+explain
+update lineitem set l_tax = (l_tax*100+1)/100 where $c4;
+eval
+update lineitem set l_tax = (l_tax*100+1)/100 where $c4;
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+
+eval
+update lineitem set l_tax = (l_tax*100-1)/100 where $c4;
+eval
+select l_orderkey, l_linenumber, l_tax from lineitem where $c4;
+
+
+--echo # FirstMatch
+--echo # ==========
+
+set optimizer_switch='materialization=off';
+
+let $c5=
+ c_nationkey in (select n_nationkey from nation
+ where n_regionkey in (1,2))
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-10-09' and '1993-06-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c5;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c5;
+eval
+select c_name, c_acctbal from customer where $c5;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal+10 where $c5;
+eval
+explain format=json
+update customer set c_acctbal = c_acctbal+10 where $c5;
+eval
+update customer set c_acctbal = c_acctbal+10 where $c5;
+eval
+select c_name, c_acctbal from customer where $c5;
+
+eval
+update customer set c_acctbal = c_acctbal-10 where $c5;
+eval
+select c_name, c_acctbal from customer where $c5;
+
+set optimizer_switch='materialization=default';
+
+let $c6=
+ c_nationkey in (select n_nationkey from nation where n_name='PERU')
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between "1992-01-09" and "1993-01-08");
+
+eval
+explain
+select c_name, c_acctbal from customer where $c6;
+eval
+select c_name, c_acctbal from customer where $c6;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal+20 where $c6;
+eval
+update customer set c_acctbal = c_acctbal+20 where $c6;
+eval
+select c_name, c_acctbal from customer where $c6;
+
+eval
+update customer set c_acctbal = c_acctbal-20 where $c6;
+eval
+select c_name, c_acctbal from customer where $c6;
+
+--echo # Materialization
+--echo # ===============
+
+set optimizer_switch='firstmatch=off';
+
+let $c7=
+ c_nationkey in (select n_nationkey from nation where
+ n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
+ and
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between "1992-01-09" and "1995-01-08");
+
+eval
+explain
+select c_name, c_acctbal from customer where $c7;
+eval
+select c_name, c_acctbal from customer where $c7;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal+20 where $c7;
+eval
+update customer set c_acctbal = c_acctbal+20 where $c7;
+eval
+select c_name, c_acctbal from customer where $c7;
+
+eval
+update customer set c_acctbal = c_acctbal-20 where $c7;
+eval
+select c_name, c_acctbal from customer where $c7;
+
+set optimizer_switch='firstmatch=default';
+
+let $c8=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1993-03-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c8;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c8;
+eval
+select c_name, c_acctbal from customer where $c8;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal+5 where $c8;
+eval
+explain format=json
+update customer set c_acctbal = c_acctbal+5 where $c8;
+eval
+update customer set c_acctbal = c_acctbal+5 where $c8;
+eval
+select c_name, c_acctbal from customer where $c8;
+
+eval
+update customer set c_acctbal = c_acctbal-5 where $c8;
+eval
+select c_name, c_acctbal from customer where $c8;
+
+
+let $c9=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-06-09' and '1993-01-08');
+
+eval
+explain
+select c_name, c_acctbal from customer where $c9;
+eval
+select c_name, c_acctbal from customer where $c9;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal+1 where $c9;
+eval
+update customer set c_acctbal = c_acctbal+1 where $c9;
+eval
+select c_name, c_acctbal from customer where $c9;
+
+eval
+update customer set c_acctbal = c_acctbal-1 where $c9;
+eval
+select c_name, c_acctbal from customer where $c9;
+
+
+
+--echo # Materialization SJM
+--echo # ===================
+
+let $c10=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1992-03-08'
+ group by o_custkey having count(o_custkey) > 1);
+
+eval
+explain
+select c_name, c_acctbal from customer where $c10;
+eval
+explain format=json
+select c_name, c_acctbal from customer where $c10;
+eval
+select c_name, c_acctbal from customer where $c10;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal-5 where $c10;
+eval
+explain format=json
+update customer set c_acctbal = c_acctbal-5 where $c10;
+eval
+update customer set c_acctbal = c_acctbal-5 where $c10;
+eval
+select c_name, c_acctbal from customer where $c10;
+
+eval
+update customer set c_acctbal = c_acctbal+5 where $c10;
+eval
+select c_name, c_acctbal from customer where $c10;
+
+
+let $c11=
+ c_custkey in (select o_custkey from orders
+ where o_orderDATE between '1992-01-09' and '1993-03-08'
+ group by o_custkey having count(o_custkey) > 5);
+
+eval
+explain
+select c_name, c_acctbal from customer where $c11;
+eval
+select c_name, c_acctbal from customer where $c11;
+
+eval
+explain
+update customer set c_acctbal = c_acctbal-1 where $c11;
+eval
+update customer set c_acctbal = c_acctbal-1 where $c11;
+eval
+select c_name, c_acctbal from customer where $c11;
+
+eval
+update customer set c_acctbal = c_acctbal+1 where $c11;
+eval
+select c_name, c_acctbal from customer where $c11;
+
+
+--echo # Pullout PS
+--echo # ==========
+
+eval
+prepare stmt from "
+update orders set o_totalprice = o_totalprice+? where $c1;
+";
+
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+set @a1=-20;
+execute stmt using @a1;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+set @a2=-10;
+execute stmt using @a2;
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+execute stmt using -(@a1+@a2);
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+deallocate prepare stmt;
+
+
+--echo # FirstMatch PS
+--echo # =============
+
+set optimizer_switch='materialization=off';
+
+eval
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where $c5;
+";
+
+eval
+select c_name, c_acctbal from customer where $c5;
+set @a1=15;
+execute stmt using @a1;
+eval
+select c_name, c_acctbal from customer where $c5;
+set @a2=5;
+execute stmt using @a2;
+eval
+select c_name, c_acctbal from customer where $c5;
+execute stmt using -(@a1+@a2);
+eval
+select c_name, c_acctbal from customer where $c5;
+
+deallocate prepare stmt;
+
+set optimizer_switch='materialization=default';
+
+--echo # Materialization PS
+--echo # ==================
+
+eval
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where $c8;
+";
+
+eval
+select c_name, c_acctbal from customer where $c8;
+set @a1=7;
+execute stmt using @a1;
+eval
+select c_name, c_acctbal from customer where $c8;
+set @a2=3;
+execute stmt using @a2;
+eval
+select c_name, c_acctbal from customer where $c8;
+execute stmt using -(@a1+@a2);
+eval
+select c_name, c_acctbal from customer where $c8;
+
+deallocate prepare stmt;
+
+
+--echo # Materialization SJM PS
+--echo # ======================
+
+eval
+prepare stmt from "
+update customer set c_acctbal = c_acctbal+? where $c10;
+";
+
+eval
+select c_name, c_acctbal from customer where $c10;
+set @a1=-2;
+execute stmt using @a1;
+eval
+select c_name, c_acctbal from customer where $c10;
+set @a2=-1;
+execute stmt using @a2;
+eval
+select c_name, c_acctbal from customer where $c10;
+execute stmt using -(@a1+@a2);
+eval
+select c_name, c_acctbal from customer where $c10;
+
+deallocate prepare stmt;
+
+
+--echo # Pullout SP
+--echo # ==========
+
+eval
+create procedure p(d int)
+update orders set o_totalprice = o_totalprice+d where $c1;
+
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+call p(-10);
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+call p(-20);
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+call p(10+20);
+eval
+select o_orderkey, o_totalprice from orders where $c1;
+
+drop procedure p;
+
+
+--echo # FirstMatch SP
+--echo # =============
+
+set optimizer_switch='materialization=off';
+
+eval
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where $c5;
+
+eval
+select c_name, c_acctbal from customer where $c5;
+call p(5);
+eval
+select c_name, c_acctbal from customer where $c5;
+call p(15);
+eval
+select c_name, c_acctbal from customer where $c5;
+call p(-(5+15));
+eval
+select c_name, c_acctbal from customer where $c5;
+
+drop procedure p;
+
+set optimizer_switch='materialization=default';
+
+
+--echo # Materialization SP
+--echo # ==================
+
+eval
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where $c8;
+
+eval
+select c_name, c_acctbal from customer where $c8;
+call p(3);
+eval
+select c_name, c_acctbal from customer where $c8;
+call p(7);
+eval
+select c_name, c_acctbal from customer where $c8;
+call p(-(3+7));
+eval
+select c_name, c_acctbal from customer where $c8;
+
+drop procedure p;
+
+
+--echo # Materialization SJM SP
+--echo # ======================
+
+eval
+create procedure p(d int)
+update customer set c_acctbal = c_acctbal+d where $c10;
+
+eval
+select c_name, c_acctbal from customer where $c10;
+call p(-1);
+eval
+select c_name, c_acctbal from customer where $c10;
+call p(-2);
+eval
+select c_name, c_acctbal from customer where $c10;
+call p(1+2);
+eval
+select c_name, c_acctbal from customer where $c10;
+
+drop procedure p;
+
+--echo # Checking limitations
+--echo # ====================
+
+let $c11=
+ o_orderDATE between '1992-01-01' and '1992-06-30' and
+ o_custkey in (select c_custkey from customer
+ where c_nationkey in (1,2));
+
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+--echo # Should not use semi-join conversion because has ORDER BY ... LIMIT
+eval
+explain
+update orders set o_totalprice = o_totalprice-50 where $c11
+order by o_totalprice limit 500;
+eval
+update orders set o_totalprice = o_totalprice-50 where $c11
+order by o_totalprice limit 500;
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+eval
+update orders set o_totalprice = o_totalprice+50 where $c11
+order by o_totalprice limit 500;
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+
+--echo # Should use semi-join converion
+eval
+explain
+update orders set o_totalprice = o_totalprice-50 where $c11;
+eval
+update orders set o_totalprice = o_totalprice-50 where $c11;
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+eval
+update orders set o_totalprice = o_totalprice+50 where $c11;
+eval
+select o_orderkey, o_totalprice from orders where $c11;
+
+CREATE TABLE partsupp_small (
+ ps_partkey int(11) NOT NULL DEFAULT '0',
+ ps_suppkey int(11) NOT NULL DEFAULT '0',
+ ps_availqty int(11) DEFAULT NULL,
+ ps_supplycost double DEFAULT NULL,
+ ps_comment varchar(199) DEFAULT NULL,
+ PRIMARY KEY (ps_partkey,ps_suppkey),
+ KEY i_ps_partkey (ps_partkey),
+ KEY i_ps_suppkey (ps_suppkey)
+);
+
+create index i_ps_sup_part on partsupp_small(ps_suppkey, ps_partkey);
+insert into partsupp_small select * from partsupp where ps_partkey <50;
+analyze table partsupp_small persistent for all;
+
+--echo # LooseScan
+--echo # =========
+
+let $c12 = l_suppkey in
+ (select ps_suppkey from partsupp_small
+ where ps_partkey in (1,2,3));
+
+eval
+explain
+select count(*) from lineitem where $c12;
+eval
+explain format=json
+select count(*) from lineitem where $c12;
+eval
+select count(*) from lineitem where $c12;
+let $l_count =
+ query_get_value('select count(*) as a from lineitem where $c12;', a, 1);
+let $l_old_sum =
+ query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c12;', a, 1
+ );
+eval select $l_count as count, $l_old_sum as old_sum;
+
+eval
+explain
+update lineitem set l_extendedprice=l_extendedprice+10 where $c12;
+eval
+explain format=json
+update lineitem set l_extendedprice=l_extendedprice+10 where $c12;
+eval
+update lineitem set l_extendedprice=l_extendedprice+10 where $c12;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+10*$l_count) as 'old_sum+10*count'
+ from lineitem where $c12;
+
+eval
+update lineitem set l_extendedprice=l_extendedprice-10 where $c12;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c12;
+
+
+--echo # LooseScan PS
+--echo # ============
+
+eval
+prepare stmt from "
+update lineitem set l_extendedprice=l_extendedprice+? where $c12;
+";
+
+let $l_count = query_get_value('select count(*) as a
+ from lineitem where $c12;', a, 1 );
+let $l_old_sum = query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c12;', a, 1 );
+eval select $l_count as count, $l_old_sum as old_sum;
+eval
+set @a1=20;
+execute stmt using @a1;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+20*$l_count) as 'old_sum+20*count'
+ from lineitem where $c12;
+set @a2=10;
+execute stmt using @a2;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+30*$l_count) as 'old_sum+30*count'
+ from lineitem where $c12;
+execute stmt using -(@a1+@a2);
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c12;
+
+deallocate prepare stmt;
+
+--echo # LooseScan SP
+--echo # ============
+
+eval
+create procedure p(d int)
+update lineitem set l_extendedprice=l_extendedprice+d where $c12;
+
+let $l_count = query_get_value('select count(*) as a
+ from lineitem where $c12;', a, 1 );
+let $l_old_sum = query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c12;', a, 1 );
+eval select $l_count as count, $l_old_sum as old_sum;
+eval
+call p(10);
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+10*$l_count) as 'old_sum+10*count'
+ from lineitem where $c12;
+call p(20);
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+30*$l_count) as 'old_sum+30*count'
+ from lineitem where $c12;
+call p(-(10+20));
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c12;
+
+drop procedure p;
+
+--echo # DuplicateWeedout
+--echo # ================
+
+set @tmp_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='materialization=off';
+
+analyze table lineitem;
+analyze table orders;
+
+let $c13 = l_partkey in (
+ select ps_partkey
+ from partsupp_small join lineitem on ps_partkey=l_partkey
+ where ps_suppkey in (
+ select s_suppkey from supplier where s_suppkey < 2
+ )
+);
+
+eval
+explain
+select count(*) from lineitem where $c13;
+eval
+explain format=json
+select count(*) from lineitem where $c13;
+eval
+select count(*) from lineitem where $c13;
+
+let $l_count = query_get_value('select count(*) as a
+ from lineitem where $c13;', a, 1 );
+let $l_old_sum = query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c13;', a, 1 );
+eval select $l_count as count, $l_old_sum as old_sum;
+
+eval
+explain
+update lineitem set l_extendedprice=l_extendedprice+10 where $c13;
+eval
+explain format=json
+update lineitem set l_extendedprice=l_extendedprice+10 where $c13;
+eval
+update lineitem set l_extendedprice=l_extendedprice+10 where $c13;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+10*$l_count) as 'old_sum+10*count'
+ from lineitem where $c13;
+
+eval
+update lineitem set l_extendedprice=l_extendedprice-10 where $c13;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c13;
+
+
+--echo # DuplicateWeedout PS
+--echo # ===================
+
+eval
+prepare stmt from "
+update lineitem set l_extendedprice=l_extendedprice+? where $c13;
+";
+
+let $l_count =
+ query_get_value('select count(*) as a
+ from lineitem where $c13;', a, 1 );
+let $l_old_sum =
+ query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c13;', a, 1);
+eval select $l_count as count, $l_old_sum as old_sum;
+eval
+set @a1=20;
+execute stmt using @a1;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+20*$l_count) as 'old_sum+20*count'
+ from lineitem where $c13;
+set @a2=10;
+execute stmt using @a2;
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+30*$l_count) as 'old_sum+30*count'
+ from lineitem where $c13;
+execute stmt using -(@a1+@a2);
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c13;
+
+deallocate prepare stmt;
+
+--echo # DuplicateWeedout SP
+--echo # ===================
+
+eval
+create procedure p(d int)
+update lineitem set l_extendedprice=l_extendedprice+d where $c13;
+
+let $l_count = query_get_value('select count(*) as a
+ from lineitem where $c13;', a, 1 );
+let $l_old_sum = query_get_value('select ROUND(sum(l_extendedprice),2) as a
+ from lineitem where $c13;', a, 1 );
+eval select $l_count as count, $l_old_sum as old_sum;
+eval
+call p(10);
+
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+10*$l_count) as 'old_sum+10*count'
+ from lineitem where $c13;
+call p(20);
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ ($l_old_sum+30*$l_count) as 'old_sum+30*count'
+ from lineitem where $c13;
+call p(-(10+20));
+eval
+select ROUND(sum(l_extendedprice),2), $l_count as count,
+ $l_old_sum as old_sum from lineitem where $c13;
+
+drop procedure p;
+set @@optimizer_switch=@tmp_optimizer_switch;
+
+drop table partsupp_small;
+
+DROP DATABASE dbt3_s001;
diff --git a/mysql-test/main/update_use_source.result b/mysql-test/main/update_use_source.result
index d61bff04e0d..d756775226c 100644
--- a/mysql-test/main/update_use_source.result
+++ b/mysql-test/main/update_use_source.result
@@ -1,4 +1,16 @@
-create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDB STATS_PERSISTENT=0;
+set @save_default_engine=@@default_storage_engine;
+#######################################
+# #
+# Engine InnoDB #
+# #
+#######################################
+set global innodb_stats_persistent=1;
+set default_storage_engine=InnoDB;
+create table t1 (old_c1 integer,
+old_c2 integer,
+c1 integer,
+c2 integer,
+c3 integer);
create view v1 as select * from t1 where c2=2;
create trigger trg_t1 before update on t1 for each row
begin
@@ -6,37 +18,39 @@ set new.old_c1=old.c1;
set new.old_c2=old.c2;
end;
/
-insert into t1(c1,c2,c3) values (1,1,1);
-insert into t1(c1,c2,c3) values (1,2,2);
-insert into t1(c1,c2,c3) values (1,3,3);
-insert into t1(c1,c2,c3) values (2,1,4);
-insert into t1(c1,c2,c3) values (2,2,5);
-insert into t1(c1,c2,c3) values (2,3,6);
-insert into t1(c1,c2,c3) values (2,4,7);
-insert into t1(c1,c2,c3) values (2,5,8);
-commit;
-select * from t1;
-old_c1 old_c2 c1 c2 c3
-NULL NULL 1 1 1
-NULL NULL 1 2 2
-NULL NULL 1 3 3
-NULL NULL 2 1 4
-NULL NULL 2 2 5
-NULL NULL 2 3 6
-NULL NULL 2 4 7
-NULL NULL 2 5 8
-Test without any index
-#
-# Update a with value from subquery on the same table, no search clause. ALL access
-#
-start transaction;
-update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+insert into t1(c1,c2,c3)
+values (1,1,1), (1,2,2), (1,3,3),
+(2,1,4), (2,2,5), (2,3,6),
+(2,4,7), (2,5,8);
+insert into t1 select NULL, NULL, c1+10,c2,c3+10 from t1;
+insert into t1 select NULL, NULL, c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1;
+#######################################
+# Test without any index #
+#######################################
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -46,20 +60,56 @@ concat(old_c1,'->',c1) c3 Changed
2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update with search clause on the same table
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
#
-start transaction;
-update t1
-set c1=10
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->10 1 *
1->10 2 *
@@ -69,19 +119,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update via RANGE or INDEX access if an index or a primary key exists
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
#
-explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
-1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
-start transaction;
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-affected rows: 4
-info: Rows matched: 4 Changed: 4 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -91,13 +177,57 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
# Update with order by
#
-start transaction;
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 order by c2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -107,18 +237,54 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-Update using a view in subquery
+# Update with a reference to view in subquery
+# in settable value
#
-start transaction;
-update t1
-set c1=c1 +(select max(a.c2)
-from v1 a
-where a.c1 = t1.c1) ;
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->3 1 *
1->3 2 *
@@ -128,19 +294,53 @@ concat(old_c1,'->',c1) c3 Changed
2->4 6 *
2->4 7 *
2->4 8 *
-rollback;
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update throw a view
+# Update view
#
-start transaction;
-update v1
-set c1=c1 + (select max(a.c2)
-from t1 a
-where a.c1 = v1.c1) +10
-where c3 > 3;
-affected rows: 1
-info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -150,20 +350,55 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with reference to the same view in subquery
#
-start transaction;
-update v1
-set c1=c1 + 1
-where c1 <2
-and exists (select 'X'
- from v1 a
-where a.c1 = v1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->2 2 *
@@ -173,22 +408,57 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with EXISTS and reference to the same view in subquery
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
update v1
-set c1=(select max(a.c1)+10
-from v1 a
-where a.c1 = v1.c1)
-where c1 <10
-and exists (select 'X'
- from v1 a
-where a.c2 = v1.c2);
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->11 2 *
@@ -198,41 +468,107 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update of the index or primary key (c3)
+# Update with IN predicand over the updated table in WHERE
#
-start transaction;
-explain update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 8
-1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
-update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
select c3 from t1;
c3
-11
-12
-13
-14
-15
-16
-17
-18
-rollback;
-#
-# update with a limit
-#
-start transaction;
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
-limit 2;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -242,19 +578,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# update with a limit and an order by
+# Update with a limit and an order by
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
order by c3 desc limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -262,22 +634,61 @@ NULL 3
NULL 4
NULL 5
NULL 6
-2->7 7 *
-2->8 8 *
-rollback;
-Test with an index on updated columns
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with an index #
+#######################################
create index t1_c2 on t1 (c2,c1);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
#
-# Update a with value from subquery on the same table, no search clause. ALL access
+# Update with value from subquery on the same table
#
-start transaction;
-update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -287,20 +698,56 @@ concat(old_c1,'->',c1) c3 Changed
2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update with search clause on the same table
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
#
-start transaction;
-update t1
-set c1=10
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->10 1 *
1->10 2 *
@@ -310,19 +757,53 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update via RANGE or INDEX access if an index or a primary key exists
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
#
-explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 2 Using where
-1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 8 Using index; FirstMatch(t1)
-start transaction;
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-affected rows: 4
-info: Rows matched: 4 Changed: 4 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -332,13 +813,55 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
# Update with order by
#
-start transaction;
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 order by c2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -348,18 +871,54 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-Update using a view in subquery
+# Update with a reference to view in subquery
+# in settable value
#
-start transaction;
-update t1
-set c1=c1 +(select max(a.c2)
-from v1 a
-where a.c1 = t1.c1) ;
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->3 1 *
1->3 2 *
@@ -369,19 +928,53 @@ concat(old_c1,'->',c1) c3 Changed
2->4 6 *
2->4 7 *
2->4 8 *
-rollback;
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update throw a view
+# Update view
#
-start transaction;
-update v1
-set c1=c1 + (select max(a.c2)
-from t1 a
-where a.c1 = v1.c1) +10
-where c3 > 3;
-affected rows: 1
-info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref t1_c2 t1_c2 5 const 8
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a index NULL t1_c2 10 NULL 32 Using where; Using index
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -391,20 +984,55 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with reference to the same view in subquery
#
-start transaction;
-update v1
-set c1=c1 + 1
-where c1 <2
-and exists (select 'X'
- from v1 a
-where a.c1 = v1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition; Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func 1 Using where; Using index
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->2 2 *
@@ -414,22 +1042,57 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with EXISTS and reference to the same view in subquery
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 5 const 8 Using where; Using index
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
update v1
-set c1=(select max(a.c1)+10
-from v1 a
-where a.c1 = v1.c1)
-where c1 <10
-and exists (select 'X'
- from v1 a
-where a.c2 = v1.c2);
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->11 2 *
@@ -439,41 +1102,107 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update of the index or primary key (c3)
+# Update with IN predicand over the updated table in WHERE
#
-start transaction;
-explain update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 8 Using where
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
-update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
select c3 from t1;
c3
-11
-12
-13
-14
-15
-16
-17
-18
-rollback;
-#
-# update with a limit
-#
-start transaction;
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
-limit 2;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -483,19 +1212,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# update with a limit and an order by
+# Update with a limit and an order by
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
order by c3 desc limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -503,22 +1268,1336 @@ NULL 3
NULL 4
NULL 5
NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
-Test with an index on updated columns
-create index t1_c3 on t1 (c3);
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update a with value from subquery on the same table, no search clause. ALL access
+# Update view
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 29 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using buffer
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+# Update with error "Subquery returns more than 1 row"
+update t1 set c2=(select c2 from t1);
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Update with error "Subquery returns more than 1 row"
+# and order by
+update t1 set c2=(select c2 from t1) order by c3;
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Duplicate value on update a primary key
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key and limit
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+# and limit
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows found
+update t1 set c1=10
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1 + 10);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+10 1 1
+10 2 2
+10 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows changed
+drop trigger trg_t1;
+update t1 set c1=c1
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 0
+info: Rows matched: 3 Changed: 0 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check call of after trigger
+#
+create or replace trigger trg_t2 after update on t1 for each row
+begin
+declare msg varchar(100);
+if (new.c3 = 5) then
+set msg=concat('in after update trigger on ',new.c3);
+SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
+end if;
+end;
+/
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check update with order by and after trigger
+#
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1)
+order by t1.c2, t1.c1;
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop view v1;
+#
+# Check update on view with check option
+#
+create view v1 as select * from t1 where c2=2 with check option;
+update v1 set c2=3 where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select max(c3) from v1) where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
+select c1,c2,c3 from t1;
+c1 c2 c3
+0 2 2
+1 1 1
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+#
+# Test on dynamic columns (blob)
+#
+create table assets (
+item_name varchar(32) primary key, -- A common attribute for all items
+dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt blue
+Thinkpad Laptop black
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years')
+WHERE item_name='Thinkpad Laptop';
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt NULL
+Thinkpad Laptop 3 years
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
+WHERE item_name in
+(select b.item_name from assets b
+where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt NULL
+Thinkpad Laptop 4 years
+UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty',
+(select COLUMN_GET(b.dynamic_cols, 'color' as char)
+from assets b
+where assets.item_name = item_name));
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt blue
+Thinkpad Laptop black
+drop table assets;
+#
+# Test on fulltext columns
+#
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+('MySQL vs MariaDB database'),
+('Oracle vs MariaDB database'),
+('PostgreSQL vs MariaDB database'),
+('MariaDB overview'),
+('Foreign keys'),
+('Primary keys'),
+('Indexes'),
+('Transactions'),
+('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+MySQL vs MariaDB database
+Oracle vs MariaDB database
+PostgreSQL vs MariaDB database
+update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5)))
+from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
+where MATCH(copy) AGAINST('keys');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('mykeyword');
+copy
+mykeyword Postg
+mykeyword Postg
+drop table ft2;
+#######################################
+# #
+# Engine Aria #
+# #
+#######################################
+set default_storage_engine=Aria;
+create table t1 (old_c1 integer,
+old_c2 integer,
+c1 integer,
+c2 integer,
+c3 integer);
+create view v1 as select * from t1 where c2=2;
+create trigger trg_t1 before update on t1 for each row
+begin
+set new.old_c1=old.c1;
+set new.old_c2=old.c2;
+end;
+/
+insert into t1(c1,c2,c3)
+values (1,1,1), (1,2,2), (1,3,3),
+(2,1,4), (2,2,5), (2,3,6),
+(2,4,7), (2,5,8);
+insert into t1 select NULL, NULL, c1+10,c2,c3+10 from t1;
+insert into t1 select NULL, NULL, c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1;
+#######################################
+# Test without any index #
+#######################################
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -528,20 +2607,56 @@ concat(old_c1,'->',c1) c3 Changed
2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update with search clause on the same table
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
#
-start transaction;
-update t1
-set c1=10
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->10 1 *
1->10 2 *
@@ -551,19 +2666,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update via RANGE or INDEX access if an index or a primary key exists
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
#
-explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY a index t1_c2 t1_c2 10 NULL 8 Using where; Using index; LooseScan
-1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 1
-start transaction;
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-affected rows: 4
-info: Rows matched: 4 Changed: 4 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -573,13 +2724,57 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
# Update with order by
#
-start transaction;
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 order by c2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -589,18 +2784,54 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-Update using a view in subquery
+# Update with a reference to view in subquery
+# in settable value
#
-start transaction;
-update t1
-set c1=c1 +(select max(a.c2)
-from v1 a
-where a.c1 = t1.c1) ;
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->3 1 *
1->3 2 *
@@ -610,19 +2841,687 @@ concat(old_c1,'->',c1) c3 Changed
2->4 6 *
2->4 7 *
2->4 8 *
-rollback;
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update throw a view
+# Update view
#
-start transaction;
-update v1
-set c1=c1 + (select max(a.c2)
-from t1 a
-where a.c1 = v1.c1) +10
-where c3 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
+2->7 7 *
+2->8 8 *
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 21 Using index condition
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 21 Using index condition
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 21 Using index condition
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 21 Using index condition
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref t1_c2 t1_c2 5 const 8
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a index NULL t1_c2 10 NULL 32 Using where; Using index
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -632,20 +3531,55 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with reference to the same view in subquery
#
-start transaction;
-update v1
-set c1=c1 + 1
-where c1 <2
-and exists (select 'X'
- from v1 a
-where a.c1 = v1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition; Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func 1 Using where; Using index
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->2 2 *
@@ -655,22 +3589,57 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with EXISTS and reference to the same view in subquery
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 5 const 8 Using where; Using index
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
update v1
-set c1=(select max(a.c1)+10
-from v1 a
-where a.c1 = v1.c1)
-where c1 <10
-and exists (select 'X'
- from v1 a
-where a.c2 = v1.c2);
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->11 2 *
@@ -680,41 +3649,107 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update of the index or primary key (c3)
+# Update with IN predicand over the updated table in WHERE
#
-start transaction;
-explain update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 8 Using where
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
-update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
select c3 from t1;
c3
-11
-12
-13
-14
-15
-16
-17
-18
-rollback;
-#
-# update with a limit
-#
-start transaction;
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
-limit 2;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -724,19 +3759,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# update with a limit and an order by
+# Update with a limit and an order by
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
order by c3 desc limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -744,23 +3815,1336 @@ NULL 3
NULL 4
NULL 5
NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
-Test with a primary key on updated columns
-drop index t1_c3 on t1;
-alter table t1 add primary key (c3);
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update a with value from subquery on the same table, no search clause. ALL access
+# Update with order by
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 30 Using index condition; Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using buffer
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+# Update with error "Subquery returns more than 1 row"
+update t1 set c2=(select c2 from t1);
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Update with error "Subquery returns more than 1 row"
+# and order by
+update t1 set c2=(select c2 from t1) order by c3;
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Duplicate value on update a primary key
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key and limit
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+# and limit
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows found
+update t1 set c1=10
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1 + 10);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+10 1 1
+10 2 2
+10 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows changed
+drop trigger trg_t1;
+update t1 set c1=c1
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 0
+info: Rows matched: 3 Changed: 0 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check call of after trigger
+#
+create or replace trigger trg_t2 after update on t1 for each row
+begin
+declare msg varchar(100);
+if (new.c3 = 5) then
+set msg=concat('in after update trigger on ',new.c3);
+SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
+end if;
+end;
+/
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 4
+2 2 2
+2 2 5
+2 3 3
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check update with order by and after trigger
+#
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1)
+order by t1.c2, t1.c1;
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 3 3
+11 2 12
+11 3 13
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 11
+2 1 14
+2 1 4
+2 2 2
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop view v1;
+#
+# Check update on view with check option
+#
+create view v1 as select * from t1 where c2=2 with check option;
+update v1 set c2=3 where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select max(c3) from v1) where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
+select c1,c2,c3 from t1;
+c1 c2 c3
+0 2 2
+1 1 1
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+#
+# Test on dynamic columns (blob)
+#
+create table assets (
+item_name varchar(32) primary key, -- A common attribute for all items
+dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO assets VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt blue
+Thinkpad Laptop black
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years')
+WHERE item_name='Thinkpad Laptop';
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt NULL
+Thinkpad Laptop 3 years
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
+WHERE item_name in
+(select b.item_name from assets b
+where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt NULL
+Thinkpad Laptop 4 years
+UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty',
+(select COLUMN_GET(b.dynamic_cols, 'color' as char)
+from assets b
+where assets.item_name = item_name));
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
+item_name color
+MariaDB T-shirt blue
+Thinkpad Laptop black
+drop table assets;
+#
+# Test on fulltext columns
+#
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
+INSERT INTO ft2(copy) VALUES
+('MySQL vs MariaDB database'),
+('Oracle vs MariaDB database'),
+('PostgreSQL vs MariaDB database'),
+('MariaDB overview'),
+('Foreign keys'),
+('Primary keys'),
+('Indexes'),
+('Transactions'),
+('Triggers');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
+copy
+MySQL vs MariaDB database
+Oracle vs MariaDB database
+PostgreSQL vs MariaDB database
+update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5)))
+from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
+where MATCH(copy) AGAINST('keys');
+SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('mykeyword');
+copy
+mykeyword Postg
+mykeyword Postg
+drop table ft2;
+#######################################
+# #
+# Engine MyISAM #
+# #
+#######################################
+set default_storage_engine=MyISAM;
+create table t1 (old_c1 integer,
+old_c2 integer,
+c1 integer,
+c2 integer,
+c3 integer);
+create view v1 as select * from t1 where c2=2;
+create trigger trg_t1 before update on t1 for each row
+begin
+set new.old_c1=old.c1;
+set new.old_c2=old.c2;
+end;
+/
+insert into t1(c1,c2,c3)
+values (1,1,1), (1,2,2), (1,3,3),
+(2,1,4), (2,2,5), (2,3,6),
+(2,4,7), (2,5,8);
+insert into t1 select NULL, NULL, c1+10,c2,c3+10 from t1;
+insert into t1 select NULL, NULL, c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+create table tmp as select * from t1;
+#######################################
+# Test without any index #
+#######################################
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -770,20 +5154,56 @@ concat(old_c1,'->',c1) c3 Changed
2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update with search clause on the same table
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
#
-start transaction;
-update t1
-set c1=10
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->10 1 *
1->10 2 *
@@ -793,19 +5213,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update via RANGE or INDEX access if an index or a primary key exists
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
#
-explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY a index t1_c2 t1_c2 10 NULL 8 Using where; Using index; LooseScan
-1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 1
-start transaction;
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-affected rows: 4
-info: Rows matched: 4 Changed: 4 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -815,13 +5271,57 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
# Update with order by
#
-start transaction;
-update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 order by c2;
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -831,18 +5331,54 @@ NULL 5
2->12 6 *
2->12 7 *
2->12 8 *
-rollback;
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-Update using a view in subquery
+# Update with a reference to view in subquery
+# in settable value
#
-start transaction;
-update t1
-set c1=c1 +(select max(a.c2)
-from v1 a
-where a.c1 = t1.c1) ;
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->3 1 *
1->3 2 *
@@ -852,19 +5388,687 @@ concat(old_c1,'->',c1) c3 Changed
2->4 6 *
2->4 7 *
2->4 8 *
-rollback;
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update throw a view
+# Update view
#
-start transaction;
-update v1
-set c1=c1 + (select max(a.c2)
-from t1 a
-where a.c1 = v1.c1) +10
-where c3 > 3;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
+2->7 7 *
+2->8 8 *
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a index NULL t1_c2 10 NULL 32 Using where; Using index; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 5 Using index; FirstMatch(t1)
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref t1_c2 t1_c2 5 const 8
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using where
+2 DEPENDENT SUBQUERY a index NULL t1_c2 10 NULL 32 Using where; Using index
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -874,20 +6078,55 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with reference to the same view in subquery
#
-start transaction;
-update v1
-set c1=c1 + 1
-where c1 <2
-and exists (select 'X'
- from v1 a
-where a.c1 = v1.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 1 Using index condition; Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func 1 Using where; Using index
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->2 2 *
@@ -897,22 +6136,57 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update through a view and using the view in subquery
+# Update view with EXISTS and reference to the same view in subquery
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+1 PRIMARY t1 ref t1_c2 t1_c2 5 const 8 Using index; FirstMatch(t1)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range t1_c2 t1_c2 10 NULL 2 Using index condition
+3 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 5 const 8 Using where; Using index
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 1 Using index
update v1
-set c1=(select max(a.c1)+10
-from v1 a
-where a.c1 = v1.c1)
-where c1 <10
-and exists (select 'X'
- from v1 a
-where a.c2 = v1.c2);
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
1->11 2 *
@@ -922,41 +6196,107 @@ NULL 4
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# Update of the index or primary key (c3)
+# Update with IN predicand over the updated table in WHERE
#
-start transaction;
-explain update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 8 Using where
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 1 Using index; FirstMatch(t1)
-update t1 set c3=c3+10 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
-affected rows: 8
-info: Rows matched: 8 Changed: 8 Warnings: 0
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
select c3 from t1;
c3
-11
-14
-12
-15
-13
-16
-17
-18
-rollback;
-#
-# update with a limit
-#
-start transaction;
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
-limit 2;
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
1->1 1
1->2 2 *
@@ -966,19 +6306,55 @@ NULL 5
NULL 6
NULL 7
NULL 8
-rollback;
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
#
-# update with a limit and an order by
+# Update with a limit and an order by
#
-start transaction;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
update t1
-set c1=(select a.c3
-from t1 a
-where a.c3 = t1.c3)
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
order by c3 desc limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-select concat(old_c1,'->',c1),c3, case when c1 != old_c1 then '*' else ' ' end "Changed" from t1 ;
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
concat(old_c1,'->',c1) c3 Changed
NULL 1
NULL 2
@@ -986,58 +6362,996 @@ NULL 3
NULL 4
NULL 5
NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
2->7 7 *
2->8 8 *
-rollback;
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using buffer
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1 Using index
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
# Update with error "Subquery returns more than 1 row"
update t1 set c2=(select c2 from t1);
ERROR 21000: Subquery returns more than 1 row
-# Update with error "Subquery returns more than 1 row" and order by
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Update with error "Subquery returns more than 1 row"
+# and order by
update t1 set c2=(select c2 from t1) order by c3;
ERROR 21000: Subquery returns more than 1 row
-Duplicate value on update a primary key
-start transaction;
-update t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Duplicate value on update a primary key
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
-rollback;
-Duplicate value on update a primary key with ignore
-start transaction;
-update ignore t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-affected rows: 4
-info: Rows matched: 4 Changed: 4 Warnings: 0
-rollback;
-Duplicate value on update a primary key and limit
-start transaction;
-update t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 limit 2;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key and limit
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
-rollback;
-Duplicate value on update a primary key with ignore and limit
-start transaction;
-update ignore t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 limit 2;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+# and limit
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
-rollback;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
# Update no rows found
-update t1
-set c1=10
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1 + 10);
-affected rows: 0
-info: Rows matched: 0 Changed: 0 Warnings: 0
+update t1 set c1=10
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1 + 10);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+10 1 1
+10 2 2
+10 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
# Update no rows changed
drop trigger trg_t1;
-start transaction;
-update t1
-set c1=c1
-where c1 <2
-and exists (select 'X'
- from t1 a
-where a.c1 = t1.c1);
+update t1 set c1=c1
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1);
affected rows: 0
info: Rows matched: 3 Changed: 0 Warnings: 0
-rollback;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
#
# Check call of after trigger
#
@@ -1050,61 +7364,208 @@ SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
end if;
end;
/
-update t1 set c1=2 where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 4
+2 2 2
+2 2 5
+2 3 3
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
#
# Check update with order by and after trigger
#
-update t1 set c1=2 where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1) order by t1.c2;
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1)
+order by t1.c2, t1.c1;
ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 3 3
+11 2 12
+11 3 13
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 11
+2 1 14
+2 1 4
+2 2 2
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
drop view v1;
#
# Check update on view with check option
#
create view v1 as select * from t1 where c2=2 with check option;
-start transaction;
update v1 set c2=3 where c1=1;
ERROR 44000: CHECK OPTION failed `test`.`v1`
-rollback;
-start transaction;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
update v1 set c2=(select max(c3) from v1) where c1=1;
ERROR 44000: CHECK OPTION failed `test`.`v1`
-rollback;
-start transaction;
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
-rollback;
-drop view v1;
-drop table t1;
-#
-# Test with a temporary table
-#
-create temporary table t1 (c1 integer, c2 integer, c3 integer) engine=InnoDb;
-insert into t1(c1,c2,c3) values (1,1,1);
-insert into t1(c1,c2,c3) values (1,2,2);
-insert into t1(c1,c2,c3) values (1,3,3);
-insert into t1(c1,c2,c3) values (2,1,4);
-insert into t1(c1,c2,c3) values (2,2,5);
-insert into t1(c1,c2,c3) values (2,3,6);
-insert into t1(c1,c2,c3) values (2,4,7);
-insert into t1(c1,c2,c3) values (2,5,8);
-start transaction;
-update t1
-set c1=(select a.c2
-from t1 a
-where a.c3 = t1.c3) limit 3;
-affected rows: 2
-info: Rows matched: 3 Changed: 2 Warnings: 0
-select * from t1 ;
+select c1,c2,c3 from t1;
c1 c2 c3
+0 2 2
1 1 1
-2 2 2
-3 3 3
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
2 1 4
2 2 5
2 3 6
2 4 7
2 5 8
-rollback;
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop table tmp;
+drop view v1;
drop table t1;
#
# Test on dynamic columns (blob)
@@ -1113,37 +7574,50 @@ create table assets (
item_name varchar(32) primary key, -- A common attribute for all items
dynamic_cols blob -- Dynamic columns will be stored here
);
-INSERT INTO assets VALUES ('MariaDB T-shirt', COLUMN_CREATE('color', 'blue', 'size', 'XL'));
-INSERT INTO assets VALUES ('Thinkpad Laptop', COLUMN_CREATE('color', 'black', 'price', 500));
-SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color FROM assets;
+INSERT INTO assets VALUES ('MariaDB T-shirt',
+COLUMN_CREATE('color', 'blue', 'size', 'XL'));
+INSERT INTO assets VALUES ('Thinkpad Laptop',
+COLUMN_CREATE('color', 'black', 'price', 500));
+SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color
+FROM assets;
item_name color
MariaDB T-shirt blue
Thinkpad Laptop black
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years') WHERE item_name='Thinkpad Laptop';
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years')
+WHERE item_name='Thinkpad Laptop';
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
item_name color
MariaDB T-shirt NULL
Thinkpad Laptop 3 years
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
-WHERE item_name in (select b.item_name
-from assets b
+UPDATE assets
+SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
+WHERE item_name in
+(select b.item_name from assets b
where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
item_name color
MariaDB T-shirt NULL
Thinkpad Laptop 4 years
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', (select COLUMN_GET(b.dynamic_cols, 'color' as char)
+UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty',
+(select COLUMN_GET(b.dynamic_cols, 'color' as char)
from assets b
where assets.item_name = item_name));
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
+SELECT item_name,
+COLUMN_GET(dynamic_cols, 'warranty' as char) AS color
+FROM assets;
item_name color
MariaDB T-shirt blue
Thinkpad Laptop black
-drop table assets ;
+drop table assets;
#
# Test on fulltext columns
#
-CREATE TABLE ft2(copy TEXT,FULLTEXT(copy)) ENGINE=MyISAM;
+CREATE TABLE ft2(copy TEXT,FULLTEXT(copy));
INSERT INTO ft2(copy) VALUES
('MySQL vs MariaDB database'),
('Oracle vs MariaDB database'),
@@ -1159,17 +7633,2488 @@ copy
MySQL vs MariaDB database
Oracle vs MariaDB database
PostgreSQL vs MariaDB database
-update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5))) from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
+update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5)))
+from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
where MATCH(copy) AGAINST('keys');
SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('mykeyword');
copy
mykeyword Postg
mykeyword Postg
drop table ft2;
+#######################################
+# #
+# Engine MEMORY #
+# #
+#######################################
+set default_storage_engine=MEMORY;
+create table t1 (old_c1 integer,
+old_c2 integer,
+c1 integer,
+c2 integer,
+c3 integer);
+create view v1 as select * from t1 where c2=2;
+create trigger trg_t1 before update on t1 for each row
+begin
+set new.old_c1=old.c1;
+set new.old_c2=old.c2;
+end;
+/
+insert into t1(c1,c2,c3)
+values (1,1,1), (1,2,2), (1,3,3),
+(2,1,4), (2,2,5), (2,3,6),
+(2,4,7), (2,5,8);
+insert into t1 select NULL, NULL, c1+10,c2,c3+10 from t1;
+insert into t1 select NULL, NULL, c1+20,c2+1,c3+20 from t1;
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+create table tmp as select * from t1;
+#######################################
+# Test without any index #
+#######################################
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
+2->7 7 *
+2->8 8 *
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with an index #
+#######################################
+create index t1_c2 on t1 (c2,c1);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
+2->7 7 *
+2->8 8 *
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL t1_c2 NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 2
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL t1_c2 NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 2 FirstMatch(t1)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,func 2 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ref t1_c2 t1_c2 10 const,test.t1.c1 2
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 2 FirstMatch(t1)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL t1_c2 NULL NULL NULL 32 Using where
+1 PRIMARY a ref t1_c2 t1_c2 10 test.t1.c2,test.t1.c1 2 FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Operation failed
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#######################################
+# Test with a primary key #
+#######################################
+drop index t1_c2 on t1;
+alter table t1 add primary key (c3);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+#
+# Update with value from subquery on the same table
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+update t1 set c1=(select a.c3 from t1 a where a.c3 = t1.c3);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+1->3 3 *
+2->4 4 *
+2->5 5 *
+2->6 6 *
+2->7 7 *
+2->8 8 *
+11->11 11
+11->12 12 *
+11->13 13 *
+12->14 14 *
+12->15 15 *
+12->16 16 *
+12->17 17 *
+12->18 18 *
+21->21 21
+21->22 22 *
+21->23 23 *
+22->24 24 *
+22->25 25 *
+22->26 26 *
+22->27 27 *
+22->28 28 *
+31->31 31
+31->32 32 *
+31->33 33 *
+32->34 34 *
+32->35 35 *
+32->36 36 *
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + possibly sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c1=10 where c1 <2
+and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->10 1 *
+1->10 2 *
+1->10 3 *
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with EXISTS subquery over the updated table
+# in WHERE + non-sargable condition
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED a ALL NULL NULL NULL NULL 32
+update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 order by c2;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+1->11 3 *
+NULL 4
+NULL 5
+2->12 6 *
+2->12 7 *
+2->12 8 *
+NULL 11
+NULL 12
+11->21 13 *
+NULL 14
+NULL 15
+12->22 16 *
+12->22 17 *
+12->22 18 *
+NULL 21
+21->31 22 *
+21->31 23 *
+NULL 24
+22->32 25 *
+22->32 26 *
+22->32 27 *
+22->32 28 *
+NULL 31
+31->41 32 *
+31->41 33 *
+NULL 34
+32->42 35 *
+32->42 36 *
+32->42 37 *
+32->42 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a reference to view in subquery
+# in settable value
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update t1 set c1=c1 +(select max(a.c2) from v1 a
+where a.c1 = t1.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->3 1 *
+1->3 2 *
+1->3 3 *
+2->4 4 *
+2->4 5 *
+2->4 6 *
+2->4 7 *
+2->4 8 *
+11->13 11 *
+11->13 12 *
+11->13 13 *
+12->14 14 *
+12->14 15 *
+12->14 16 *
+12->14 17 *
+12->14 18 *
+21->23 21 *
+21->23 22 *
+21->23 23 *
+22->24 24 *
+22->24 25 *
+22->24 26 *
+22->24 27 *
+22->24 28 *
+31->33 31 *
+31->33 32 *
+31->33 33 *
+32->34 34 *
+32->34 35 *
+32->34 36 *
+32->34 37 *
+32->34 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using where
+explain update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + (select max(a.c2) from t1 a
+where a.c1 = v1.c1) +10 where c3 > 3;
+affected rows: 7
+info: Rows matched: 7 Changed: 7 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+2->17 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+11->24 12 *
+NULL 13
+NULL 14
+12->27 15 *
+NULL 16
+NULL 17
+NULL 18
+21->35 21 *
+NULL 22
+NULL 23
+22->38 24 *
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+31->45 31 *
+NULL 32
+NULL 33
+32->48 34 *
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1 set c1=c1 + 1 where c1 <2
+and exists (select 'X' from v1 a where a.c1 = v1.c1);
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update view with EXISTS and reference to the same view in subquery
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from v1 where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where
+update v1
+set c1=(select max(a.c1)+10 from v1 a where a.c1 = v1.c1)
+where c1 <10 and exists (select 'X' from v1 a where a.c2 = v1.c2);
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+1->11 2 *
+NULL 3
+NULL 4
+2->12 5 *
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with IN predicand over the updated table in WHERE
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+explain update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+1 PRIMARY a ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1)
+update t1 set c3=c3+110 where c2 in (select distinct a.c2 from t1 a where t1.c1=a.c1);
+affected rows: 32
+info: Rows matched: 32 Changed: 32 Warnings: 0
+select c3 from t1;
+c3
+111
+112
+113
+114
+115
+116
+117
+118
+121
+122
+123
+124
+125
+126
+127
+128
+131
+132
+133
+134
+135
+136
+137
+138
+141
+142
+143
+144
+145
+146
+147
+148
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3) limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+1->1 1
+1->2 2 *
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+NULL 37
+NULL 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Update with a limit and an order by
+#
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze note The storage engine for the table doesn't support analyze
+explain select * from t1 order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using filesort
+explain update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using filesort
+2 DEPENDENT SUBQUERY a eq_ref PRIMARY PRIMARY 4 test.t1.c3 1
+update t1
+set c1=(select a.c3 from t1 a where a.c3 = t1.c3)
+order by c3 desc limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select concat(old_c1,'->',c1),c3,
+case when c1 != old_c1 then '*' else ' ' end "Changed" from t1;
+concat(old_c1,'->',c1) c3 Changed
+NULL 1
+NULL 2
+NULL 3
+NULL 4
+NULL 5
+NULL 6
+NULL 7
+NULL 8
+NULL 11
+NULL 12
+NULL 13
+NULL 14
+NULL 15
+NULL 16
+NULL 17
+NULL 18
+NULL 21
+NULL 22
+NULL 23
+NULL 24
+NULL 25
+NULL 26
+NULL 27
+NULL 28
+NULL 31
+NULL 32
+NULL 33
+NULL 34
+NULL 35
+NULL 36
+32->37 37 *
+32->38 38 *
+truncate table t1;
+insert into t1 select * from tmp;
+# Update with error "Subquery returns more than 1 row"
+update t1 set c2=(select c2 from t1);
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Update with error "Subquery returns more than 1 row"
+# and order by
+update t1 set c2=(select c2 from t1) order by c3;
+ERROR 21000: Subquery returns more than 1 row
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+# Duplicate value on update a primary key
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
+affected rows: 20
+info: Rows matched: 20 Changed: 20 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key and limit
+update t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Duplicate value on update a primary key with ignore
+# and limit
+update ignore t1 set c3=0
+where exists (select 'X' from t1 a where a.c2 = t1.c2)
+and c2 >= 3 limit 2;
+affected rows: 2
+info: Rows matched: 2 Changed: 2 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 0
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows found
+update t1 set c1=10
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1 + 10);
+affected rows: 3
+info: Rows matched: 3 Changed: 3 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+10 1 1
+10 2 2
+10 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+# Update no rows changed
+drop trigger trg_t1;
+update t1 set c1=c1
+where c1 <2 and exists (select 'X' from t1 a where a.c1 = t1.c1);
+affected rows: 0
+info: Rows matched: 3 Changed: 0 Warnings: 0
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check call of after trigger
+#
+create or replace trigger trg_t2 after update on t1 for each row
+begin
+declare msg varchar(100);
+if (new.c3 = 5) then
+set msg=concat('in after update trigger on ',new.c3);
+SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
+end if;
+end;
+/
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 4
+2 2 2
+2 2 5
+2 3 3
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+#
+# Check update with order by and after trigger
+#
+update t1 set c1=2
+where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1)
+order by t1.c2, t1.c1;
+ERROR 45000: in after update trigger on 5
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 3 3
+11 2 12
+11 3 13
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 1
+2 1 11
+2 1 14
+2 1 4
+2 2 2
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop view v1;
+#
+# Check update on view with check option
+#
+create view v1 as select * from t1 where c2=2 with check option;
+update v1 set c2=3 where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select max(c3) from v1) where c1=1;
+ERROR 44000: CHECK OPTION failed `test`.`v1`
+select c1,c2,c3 from t1;
+c1 c2 c3
+1 1 1
+1 2 2
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
+select c1,c2,c3 from t1;
+c1 c2 c3
+0 2 2
+1 1 1
+1 3 3
+11 1 11
+11 2 12
+11 3 13
+12 1 14
+12 2 15
+12 3 16
+12 4 17
+12 5 18
+2 1 4
+2 2 5
+2 3 6
+2 4 7
+2 5 8
+21 2 21
+21 3 22
+21 4 23
+22 2 24
+22 3 25
+22 4 26
+22 5 27
+22 6 28
+31 2 31
+31 3 32
+31 4 33
+32 2 34
+32 3 35
+32 4 36
+32 5 37
+32 6 38
+truncate table t1;
+insert into t1 select * from tmp;
+drop table tmp;
+drop view v1;
+drop table t1;
+set @@default_storage_engine=@save_default_engine;
#
# Test with MyISAM
#
-create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=MyISAM;
+create table t1 (old_c1 integer,
+old_c2 integer,
+c1 integer,
+c2 integer,
+c3 integer) engine=MyISAM;
insert t1 (c1,c2,c3) select 0,seq,seq%10 from seq_1_to_500;
insert t1 (c1,c2,c3) select 1,seq,seq%10 from seq_1_to_400;
insert t1 (c1,c2,c3) select 2,seq,seq%10 from seq_1_to_300;
@@ -1189,13 +10134,14 @@ count(*)
140
drop table t1;
#
-# Test error on multi_update conversion on view with order by or limit
+# Test error on multi_update conversion on view
+# with order by or limit
#
create table t1 (c1 integer) engine=InnoDb;
create table t2 (c1 integer) engine=InnoDb;
-create view v1 as select t1.c1 as "t1c1" ,t2.c1 as "t2c1" from t1,t2 where t1.c1=t2.c1;
+create view v1 as select t1.c1 as "t1c1" ,t2.c1 as "t2c1"
+ from t1,t2 where t1.c1=t2.c1;
update v1 set t1c1=2 order by 1;
-ERROR 42S22: Unknown column '1' in 'order clause'
update v1 set t1c1=2 limit 1;
drop table t1;
drop table t2;
diff --git a/mysql-test/main/update_use_source.test b/mysql-test/main/update_use_source.test
index 1b765138a18..ec27fa4d03c 100644
--- a/mysql-test/main/update_use_source.test
+++ b/mysql-test/main/update_use_source.test
@@ -2,221 +2,55 @@
--source include/have_innodb.inc
--source include/no_valgrind_without_big.inc
-create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDB STATS_PERSISTENT=0;
-create view v1 as select * from t1 where c2=2;
-delimiter /;
-create trigger trg_t1 before update on t1 for each row
-begin
- set new.old_c1=old.c1;
- set new.old_c2=old.c2;
-end;
-/
-delimiter ;/
-
-insert into t1(c1,c2,c3) values (1,1,1);
-insert into t1(c1,c2,c3) values (1,2,2);
-insert into t1(c1,c2,c3) values (1,3,3);
-insert into t1(c1,c2,c3) values (2,1,4);
-insert into t1(c1,c2,c3) values (2,2,5);
-insert into t1(c1,c2,c3) values (2,3,6);
-insert into t1(c1,c2,c3) values (2,4,7);
-insert into t1(c1,c2,c3) values (2,5,8);
-
-commit;
-select * from t1;
-
---echo Test without any index
+set @save_default_engine=@@default_storage_engine;
+
+--echo #######################################
+--echo # #
+--echo # Engine InnoDB #
+--echo # #
+--echo #######################################
+set global innodb_stats_persistent=1;
+set default_storage_engine=InnoDB;
--source include/update_use_source.inc
-
---echo Test with an index on updated columns
-create index t1_c2 on t1 (c2,c1);
+--source include/update_use_source_ext.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine Aria #
+--echo # #
+--echo #######################################
+set default_storage_engine=Aria;
--source include/update_use_source.inc
-
---echo Test with an index on updated columns
-create index t1_c3 on t1 (c3);
+--source include/update_use_source_ext.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine MyISAM #
+--echo # #
+--echo #######################################
+set default_storage_engine=MyISAM;
--source include/update_use_source.inc
-
---echo Test with a primary key on updated columns
-drop index t1_c3 on t1;
-alter table t1 add primary key (c3);
+--source include/update_use_source_ext.inc
+
+--echo #######################################
+--echo # #
+--echo # Engine MEMORY #
+--echo # #
+--echo #######################################
+set default_storage_engine=MEMORY;
--source include/update_use_source.inc
---echo # Update with error "Subquery returns more than 1 row"
---error ER_SUBQUERY_NO_1_ROW
-update t1 set c2=(select c2 from t1);
-
---echo # Update with error "Subquery returns more than 1 row" and order by
---error ER_SUBQUERY_NO_1_ROW
-update t1 set c2=(select c2 from t1) order by c3;
-
--- echo Duplicate value on update a primary key
-start transaction;
---error ER_DUP_ENTRY
-update t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-rollback;
-
--- echo Duplicate value on update a primary key with ignore
-start transaction;
---enable_info ONCE
-update ignore t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
-rollback;
-
--- echo Duplicate value on update a primary key and limit
-start transaction;
---error ER_DUP_ENTRY
-update t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 limit 2;
-rollback;
-
--- echo Duplicate value on update a primary key with ignore and limit
-start transaction;
---enable_info ONCE
-update ignore t1 set c3=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3 limit 2;
-rollback;
-
---echo # Update no rows found
---enable_info ONCE
-update t1
- set c1=10
- where c1 <2
- and exists (select 'X'
- from t1 a
- where a.c1 = t1.c1 + 10);
-
---echo # Update no rows changed
-drop trigger trg_t1;
-start transaction;
---enable_info ONCE
-update t1
- set c1=c1
- where c1 <2
- and exists (select 'X'
- from t1 a
- where a.c1 = t1.c1);
-rollback;
-
---echo #
---echo # Check call of after trigger
---echo #
-
-delimiter /;
-create or replace trigger trg_t2 after update on t1 for each row
-begin
- declare msg varchar(100);
- if (new.c3 = 5) then
- set msg=concat('in after update trigger on ',new.c3);
- SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
- end if;
-end;
-/
-delimiter ;/
---error 1644
-update t1 set c1=2 where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1);
-
---echo #
---echo # Check update with order by and after trigger
---echo #
-
---error 1644
-update t1 set c1=2 where c3 in (select distinct a.c3 from t1 a where a.c1=t1.c1) order by t1.c2;
-
-drop view v1;
---echo #
---echo # Check update on view with check option
---echo #
-
-create view v1 as select * from t1 where c2=2 with check option;
-
-start transaction;
--- error 1369
-update v1 set c2=3 where c1=1;
-rollback;
-
-start transaction;
--- error 1369
-update v1 set c2=(select max(c3) from v1) where c1=1;
-rollback;
-
-start transaction;
-update v1 set c2=(select min(va.c3) from v1 va), c1=0 where c1=1;
-rollback;
-
-drop view v1;
-drop table t1;
-
---echo #
---echo # Test with a temporary table
---echo #
-
-create temporary table t1 (c1 integer, c2 integer, c3 integer) engine=InnoDb;
-insert into t1(c1,c2,c3) values (1,1,1);
-insert into t1(c1,c2,c3) values (1,2,2);
-insert into t1(c1,c2,c3) values (1,3,3);
-insert into t1(c1,c2,c3) values (2,1,4);
-insert into t1(c1,c2,c3) values (2,2,5);
-insert into t1(c1,c2,c3) values (2,3,6);
-insert into t1(c1,c2,c3) values (2,4,7);
-insert into t1(c1,c2,c3) values (2,5,8);
-
-start transaction;
---enable_info ONCE
-update t1
- set c1=(select a.c2
- from t1 a
- where a.c3 = t1.c3) limit 3;
-select * from t1 ;
-rollback;
-drop table t1;
-
---echo #
---echo # Test on dynamic columns (blob)
---echo #
-
-create table assets (
- item_name varchar(32) primary key, -- A common attribute for all items
- dynamic_cols blob -- Dynamic columns will be stored here
-);
-INSERT INTO assets VALUES ('MariaDB T-shirt', COLUMN_CREATE('color', 'blue', 'size', 'XL'));
-INSERT INTO assets VALUES ('Thinkpad Laptop', COLUMN_CREATE('color', 'black', 'price', 500));
-SELECT item_name, COLUMN_GET(dynamic_cols, 'color' as char) AS color FROM assets;
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '3 years') WHERE item_name='Thinkpad Laptop';
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', '4 years')
- WHERE item_name in (select b.item_name
- from assets b
- where COLUMN_GET(b.dynamic_cols, 'color' as char) ='black');
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
-
-UPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, 'warranty', (select COLUMN_GET(b.dynamic_cols, 'color' as char)
- from assets b
- where assets.item_name = item_name));
-SELECT item_name, COLUMN_GET(dynamic_cols, 'warranty' as char) AS color FROM assets;
-drop table assets ;
-
---echo #
---echo # Test on fulltext columns
---echo #
-CREATE TABLE ft2(copy TEXT,FULLTEXT(copy)) ENGINE=MyISAM;
-INSERT INTO ft2(copy) VALUES
- ('MySQL vs MariaDB database'),
- ('Oracle vs MariaDB database'),
- ('PostgreSQL vs MariaDB database'),
- ('MariaDB overview'),
- ('Foreign keys'),
- ('Primary keys'),
- ('Indexes'),
- ('Transactions'),
- ('Triggers');
-SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('database');
-update ft2 set copy = (select max(concat('mykeyword ',substr(b.copy,1,5))) from ft2 b WHERE MATCH(b.copy) AGAINST('database'))
- where MATCH(copy) AGAINST('keys');
-SELECT * FROM ft2 WHERE MATCH(copy) AGAINST('mykeyword');
-drop table ft2;
+set @@default_storage_engine=@save_default_engine;
--echo #
--echo # Test with MyISAM
--echo #
-create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=MyISAM;
+create table t1 (old_c1 integer,
+ old_c2 integer,
+ c1 integer,
+ c2 integer,
+ c3 integer) engine=MyISAM;
insert t1 (c1,c2,c3) select 0,seq,seq%10 from seq_1_to_500;
insert t1 (c1,c2,c3) select 1,seq,seq%10 from seq_1_to_400;
insert t1 (c1,c2,c3) select 2,seq,seq%10 from seq_1_to_300;
@@ -232,13 +66,15 @@ drop table t1;
--echo #
---echo # Test error on multi_update conversion on view with order by or limit
+--echo # Test error on multi_update conversion on view
+--echo # with order by or limit
--echo #
create table t1 (c1 integer) engine=InnoDb;
create table t2 (c1 integer) engine=InnoDb;
-create view v1 as select t1.c1 as "t1c1" ,t2.c1 as "t2c1" from t1,t2 where t1.c1=t2.c1;
---error ER_BAD_FIELD_ERROR
+create view v1 as select t1.c1 as "t1c1" ,t2.c1 as "t2c1"
+ from t1,t2 where t1.c1=t2.c1;
+# 'order by 1' should be considered as in 'select * from v1 order 1'
update v1 set t1c1=2 order by 1;
update v1 set t1c1=2 limit 1;
drop table t1;
diff --git a/mysql-test/main/variables.result b/mysql-test/main/variables.result
index f6817a2a4d2..9b54a24be71 100644
--- a/mysql-test/main/variables.result
+++ b/mysql-test/main/variables.result
@@ -777,16 +777,16 @@ select @@lc_time_names;
@@lc_time_names
en_US
LC_TIME_NAMES: testing locale with the last ID:
-set lc_time_names=110;
+set lc_time_names=111;
select @@lc_time_names;
@@lc_time_names
-rm_CH
+ka_GE
LC_TIME_NAMES: testing a number beyond the valid ID range:
-set lc_time_names=111;
-ERROR HY000: Unknown locale: '111'
+set lc_time_names=112;
+ERROR HY000: Unknown locale: '112'
select @@lc_time_names;
@@lc_time_names
-rm_CH
+ka_GE
LC_TIME_NAMES: testing that 0 is en_US:
set lc_time_names=0;
select @@lc_time_names;
diff --git a/mysql-test/main/variables.test b/mysql-test/main/variables.test
index c8b36925df6..89267560ca6 100644
--- a/mysql-test/main/variables.test
+++ b/mysql-test/main/variables.test
@@ -538,12 +538,13 @@ set lc_time_names=NULL;
--error ER_UNKNOWN_LOCALE
set lc_time_names=-1;
select @@lc_time_names;
+# note same boundary condition tests in sys_vars.lc_time_names_basic
--echo LC_TIME_NAMES: testing locale with the last ID:
-set lc_time_names=110;
+set lc_time_names=111;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing a number beyond the valid ID range:
--error ER_UNKNOWN_LOCALE
-set lc_time_names=111;
+set lc_time_names=112;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing that 0 is en_US:
set lc_time_names=0;
diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result
index 1c720f215f8..cfb8f7df60e 100644
--- a/mysql-test/main/view_grant.result
+++ b/mysql-test/main/view_grant.result
@@ -676,6 +676,7 @@ ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table `mys
UPDATE mysqltest1.v_ts SET x= 200;
ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table `mysqltest1`.`v_ts`
UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100;
+ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_tu'
UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100;
UPDATE mysqltest1.v_tu SET x= 200;
DELETE FROM mysqltest1.v_ts WHERE x= 200;
diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test
index 9094c616a1f..a7990b44636 100644
--- a/mysql-test/main/view_grant.test
+++ b/mysql-test/main/view_grant.test
@@ -809,6 +809,7 @@ INSERT INTO mysqltest1.v_ti VALUES (100);
UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100;
--error ER_TABLEACCESS_DENIED_ERROR
UPDATE mysqltest1.v_ts SET x= 200;
+--error ER_COLUMNACCESS_DENIED_ERROR
UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100;
UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100;
UPDATE mysqltest1.v_tu SET x= 200;
diff --git a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test
index 0139b9fb817..1bd69365f68 100644
--- a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test
+++ b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test
@@ -30,8 +30,10 @@ insert into t8 values (1, 'publicmessage');
insert into t9 values (1, 'pugliccompressedaaaaaaaaabbbbbbbbbbbbbbccccccccccccccc');
--echo # should list tables t1-t6
+--sorted_result
SELECT NAME,ENCRYPTION_SCHEME,CURRENT_KEY_ID FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'enctests%';
--echo # should list tables t7-t9
+--sorted_result
SELECT NAME,ENCRYPTION_SCHEME,CURRENT_KEY_ID FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 and NAME LIKE 'enctests%';
--let $MYSQLD_DATADIR=`select @@datadir`
diff --git a/mysql-test/suite/encryption/t/innodb_encryption_is.test b/mysql-test/suite/encryption/t/innodb_encryption_is.test
index 52574aa2b9d..9e15cebb1da 100644
--- a/mysql-test/suite/encryption/t/innodb_encryption_is.test
+++ b/mysql-test/suite/encryption/t/innodb_encryption_is.test
@@ -9,6 +9,7 @@ INSERT INTO t2 VALUES ('foobar');
#
# MDEV-9640: Add used key_id to INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
#
+--sorted_result
SELECT NAME, ENCRYPTION_SCHEME, MIN_KEY_VERSION, CURRENT_KEY_VERSION,
CURRENT_KEY_ID
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
diff --git a/mysql-test/suite/engines/iuds/r/update_delete_number.result b/mysql-test/suite/engines/iuds/r/update_delete_number.result
index 1cd2a62cb56..1534f93b436 100644
--- a/mysql-test/suite/engines/iuds/r/update_delete_number.result
+++ b/mysql-test/suite/engines/iuds/r/update_delete_number.result
@@ -739,8 +739,21 @@ c1 c2 c3 c1 c2 c3
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
c1 c2 c3 c1 c2 c3
-DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES(254,127,1),(0,-128,2),(1,127,3),(3,NULL,5);
+INSERT INTO t2 VALUES(127,255,1),(127,1,2),(-128,0,3),(-1,NULL,5);
+DELETE FROM t1,t2 using t1,t2
+where t1.c1=(select c1 from t1 where c2 < 10) and t2.c2 < 10;
+SELECT * FROM t1;
+c1 c2 c3
+1 127 3
+254 127 1
+3 NULL 5
+SELECT * FROM t2;
+c1 c2 c3
+-1 NULL 5
+127 255 1
CREATE TABLE t3(c1 INT UNSIGNED NOT NULL PRIMARY KEY, c2 INT SIGNED NULL, c3 INT);
CREATE TABLE t4(c1 INT UNSIGNED, c2 INT);
INSERT INTO t3 VALUES(200,126,1),(250,-127,2);
@@ -981,7 +994,6 @@ create table mt1 (col1 int);
create table mt2 (col1 int);
update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1;
delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1;
-ERROR HY000: Table 'mt1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table mt1,mt2;
CREATE TABLE IF NOT EXISTS `mt1` (`id` int(11) NOT NULL auto_increment, `tst` text, `tsmt1` text, PRIMARY KEY (`id`));
CREATE TABLE IF NOT EXISTS `mt2` (`ID` int(11) NOT NULL auto_increment, `ParId` int(11) default NULL, `tst` text, `tsmt1` text, PRIMARY KEY (`ID`), KEY `IX_ParId_mt2` (`ParId`), FOREIGN KEY (`ParId`) REFERENCES `mt1` (`id`));
@@ -1852,7 +1864,6 @@ DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
c1 c2 c3 c1 c2 c3
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
CREATE TABLE t3(c1 TINYINT UNSIGNED NOT NULL PRIMARY KEY, c2 TINYINT SIGNED NULL, c3 INT);
CREATE TABLE t4(c1 TINYINT UNSIGNED, c2 INT);
INSERT INTO t3 VALUES(200,126,1),(250,-127,2);
@@ -2599,7 +2610,6 @@ DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
c1 c2 c3 c1 c2 c3
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
CREATE TABLE t3(c1 SMALLINT UNSIGNED NOT NULL PRIMARY KEY, c2 SMALLINT SIGNED NULL, c3 INT);
CREATE TABLE t4(c1 SMALLINT UNSIGNED, c2 INT);
INSERT INTO t3 VALUES(200,126,1),(250,-127,2);
@@ -3346,7 +3356,6 @@ DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
c1 c2 c3 c1 c2 c3
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
CREATE TABLE t3(c1 MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, c2 MEDIUMINT SIGNED NULL, c3 INT);
CREATE TABLE t4(c1 MEDIUMINT UNSIGNED, c2 INT);
INSERT INTO t3 VALUES(200,126,1),(250,-127,2);
@@ -4093,7 +4102,6 @@ DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
c1 c2 c3 c1 c2 c3
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
-ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
CREATE TABLE t3(c1 BIGINT UNSIGNED NOT NULL PRIMARY KEY, c2 BIGINT SIGNED NULL, c3 INT);
CREATE TABLE t4(c1 BIGINT UNSIGNED, c2 INT);
INSERT INTO t3 VALUES(200,126,1),(250,-127,2);
diff --git a/mysql-test/suite/engines/iuds/t/update_delete_number.test b/mysql-test/suite/engines/iuds/t/update_delete_number.test
index ce3f90140b2..4347d0606ae 100644
--- a/mysql-test/suite/engines/iuds/t/update_delete_number.test
+++ b/mysql-test/suite/engines/iuds/t/update_delete_number.test
@@ -285,8 +285,18 @@ SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
--sorted_result
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
---error ER_UPDATE_TABLE_USED
-DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES(254,127,1),(0,-128,2),(1,127,3),(3,NULL,5);
+INSERT INTO t2 VALUES(127,255,1),(127,1,2),(-128,0,3),(-1,NULL,5);
+# After the patch for MDEV-28883 this should not report
+# ER_UPDATE_TABLE_USED anymore
+DELETE FROM t1,t2 using t1,t2
+ where t1.c1=(select c1 from t1 where c2 < 10) and t2.c2 < 10;
+--sorted_result
+SELECT * FROM t1;
+--sorted_result
+SELECT * FROM t2;
# eq-ref join
CREATE TABLE t3(c1 INT UNSIGNED NOT NULL PRIMARY KEY, c2 INT SIGNED NULL, c3 INT);
@@ -496,7 +506,7 @@ drop table mt1, mt2, mt3;
create table mt1 (col1 int);
create table mt2 (col1 int);
update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1;
--- error ER_UPDATE_TABLE_USED
+# -- error ER_UPDATE_TABLE_USED
delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1;
drop table mt1,mt2;
@@ -865,7 +875,6 @@ SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
--sorted_result
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
---error ER_UPDATE_TABLE_USED
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
# eq-ref join
@@ -1166,7 +1175,6 @@ SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
--sorted_result
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
---error ER_UPDATE_TABLE_USED
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
# eq-ref join
@@ -1467,7 +1475,6 @@ SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
--sorted_result
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
---error ER_UPDATE_TABLE_USED
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
# eq-ref join
@@ -1768,7 +1775,6 @@ SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a2.c1=a1.c2;
--sorted_result
SELECT * FROM t1,t2 WHERE t2.c1=t1.c2;
---error ER_UPDATE_TABLE_USED
DELETE FROM t1,t2 using t1,t2 where t1.c1=(select c1 from t1);
# eq-ref join
diff --git a/mysql-test/suite/funcs_1/r/is_collations.result b/mysql-test/suite/funcs_1/r/is_collations.result
index 979b477b8bc..6007742a2a1 100644
--- a/mysql-test/suite/funcs_1/r/is_collations.result
+++ b/mysql-test/suite/funcs_1/r/is_collations.result
@@ -66,7 +66,7 @@ INSERT INTO information_schema.collations
(collation_name,character_set_name,id,is_default,is_compiled,sortlen)
VALUES ( 'cp1251_bin', 'cp1251',50, '', '',0);
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-UPDATE information_schema.collations SET description = 'just updated';
+UPDATE information_schema.collations SET collation_name = 'just updated';
Got one of the listed errors
DELETE FROM information_schema.collations WHERE table_name = 't1';
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
diff --git a/mysql-test/suite/funcs_1/t/is_collations.test b/mysql-test/suite/funcs_1/t/is_collations.test
index db34a7b77b1..aa199b512bc 100644
--- a/mysql-test/suite/funcs_1/t/is_collations.test
+++ b/mysql-test/suite/funcs_1/t/is_collations.test
@@ -83,7 +83,7 @@ INSERT INTO information_schema.collations
VALUES ( 'cp1251_bin', 'cp1251',50, '', '',0);
--error ER_DBACCESS_DENIED_ERROR,ER_NON_UPDATABLE_TABLE
-UPDATE information_schema.collations SET description = 'just updated';
+UPDATE information_schema.collations SET collation_name = 'just updated';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.collations WHERE table_name = 't1';
diff --git a/mysql-test/suite/innodb/r/innodb-system-table-view.result b/mysql-test/suite/innodb/r/innodb-system-table-view.result
index 5be25e62ae2..dfe916bc6cd 100644
--- a/mysql-test/suite/innodb/r/innodb-system-table-view.result
+++ b/mysql-test/suite/innodb/r/innodb-system-table-view.result
@@ -77,6 +77,9 @@ test/t_dynamic test/t_dynamic 33 5 Dynamic 0
test/t_redundant test/t_redundant 0 5 Redundant 0
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t_redundant DEFAULT DEFAULT MYSQLD_DATADIR/test/t_redundant.ibd
test/t_compact DEFAULT DEFAULT MYSQLD_DATADIR/test/t_compact.ibd
test/t_compressed DEFAULT 2048 MYSQLD_DATADIR/test/t_compressed.ibd
diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
index ede62417652..b51a7fb3f6d 100644
--- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
+++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
@@ -182,7 +182,7 @@ compress_pages_page_decompressed compression 0 NULL NULL NULL 0 NULL NULL NULL N
compress_pages_page_compression_error compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of page compression errors
compress_pages_encrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages encrypted
compress_pages_decrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decrypted
-index_page_splits index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page splits
+index_page_splits index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of index page splits
index_page_merge_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page merge attempts
index_page_merge_successful index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of successful index page merges
index_page_reorg_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page reorganization attempts
diff --git a/mysql-test/suite/innodb/r/innodb_status_variables.result b/mysql-test/suite/innodb/r/innodb_status_variables.result
index dcd8ff4d619..2eeed4f169a 100644
--- a/mysql-test/suite/innodb/r/innodb_status_variables.result
+++ b/mysql-test/suite/innodb/r/innodb_status_variables.result
@@ -23,6 +23,7 @@ INNODB_BUFFER_POOL_PAGES_OLD
INNODB_BUFFER_POOL_PAGES_TOTAL
INNODB_BUFFER_POOL_PAGES_LRU_FLUSHED
INNODB_BUFFER_POOL_PAGES_LRU_FREED
+INNODB_BUFFER_POOL_PAGES_SPLIT
INNODB_BUFFER_POOL_READ_AHEAD_RND
INNODB_BUFFER_POOL_READ_AHEAD
INNODB_BUFFER_POOL_READ_AHEAD_EVICTED
diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result
index eedfb681929..d17f24bd7d5 100644
--- a/mysql-test/suite/innodb/r/insert_into_empty.result
+++ b/mysql-test/suite/innodb/r/insert_into_empty.result
@@ -214,6 +214,21 @@ WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
DROP TABLE t1;
+#
+# MDEV-29975 InnoDB fails to release savepoint during bulk insert
+#
+CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
+begin;
+INSERT INTO t VALUES (0,0);
+ERROR 21S01: Column count doesn't match value count at row 1
+SAVEPOINT a;
+INSERT INTO t VALUES (0),(0);
+ERROR HY000: Got error 1 "Operation not permitted" during COMMIT
+SAVEPOINT a;
+commit;
+SELECT * FROM t;
+c
+DROP TABLE t;
# End of 10.6 tests
#
# MDEV-26947 UNIQUE column checks fail in InnoDB resulting
diff --git a/mysql-test/suite/innodb/r/online_table_rebuild.result b/mysql-test/suite/innodb/r/online_table_rebuild.result
index d4bddbc5305..46d9780decb 100644
--- a/mysql-test/suite/innodb/r/online_table_rebuild.result
+++ b/mysql-test/suite/innodb/r/online_table_rebuild.result
@@ -43,5 +43,25 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;
+#
+# MDEV-30183 Assertion `!memcmp(rec_trx_id, old_pk_trx_id->data,
+# 6 + 7)' failed in row_log_table_apply_update
+#
+set @old_sql_mode = @@sql_mode;
+set @@sql_mode="";
+CREATE TABLE t1(col_int int, col_varchar varchar(500))ENGINE=InnoDB;
+INSERT INTO t1(col_int) values(2560);
+set debug_sync="row_log_table_apply1_before SIGNAL con1_begin WAIT_FOR con1_commit";
+ALTER TABLE t1 ADD PRIMARY KEY ( col_varchar);
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR con1_begin";
+UPDATE t1 SET col_int = 2178;
+INSERT INTO t1(col_int) VALUES(3016);
+UPDATE t1 set col_int=2802;
+SET DEBUG_SYNC="now SIGNAL con1_commit";
+connection default;
+ERROR 23000: Duplicate entry '' for key 'PRIMARY'
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
disconnect con1;
SET DEBUG_SYNC=reset;
diff --git a/mysql-test/suite/innodb/r/undo_truncate.result b/mysql-test/suite/innodb/r/undo_truncate.result
index b7729020aca..c46dccfbba9 100644
--- a/mysql-test/suite/innodb/r/undo_truncate.result
+++ b/mysql-test/suite/innodb/r/undo_truncate.result
@@ -2,6 +2,11 @@ SET GLOBAL innodb_fast_shutdown=0;
# restart: --innodb_undo_tablespaces=2
SET GLOBAL innodb_undo_log_truncate = 0;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
+Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1
create table t1(keyc int primary key, c char(100)) engine = innodb;
create table t2(keyc int primary key, c char(100)) engine = innodb;
connect con1,localhost,root,,;
diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test
index ee32a2d7cac..8f7eb3a6c1f 100644
--- a/mysql-test/suite/innodb/t/insert_into_empty.test
+++ b/mysql-test/suite/innodb/t/insert_into_empty.test
@@ -235,6 +235,20 @@ SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
DROP TABLE t1;
+--echo #
+--echo # MDEV-29975 InnoDB fails to release savepoint during bulk insert
+--echo #
+CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
+begin;
+--error ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO t VALUES (0,0);
+SAVEPOINT a;
+--error ER_ERROR_DURING_COMMIT
+INSERT INTO t VALUES (0),(0);
+SAVEPOINT a;
+commit;
+SELECT * FROM t;
+DROP TABLE t;
--echo # End of 10.6 tests
--echo #
diff --git a/mysql-test/suite/innodb/t/online_table_rebuild.test b/mysql-test/suite/innodb/t/online_table_rebuild.test
index 1d34738703c..02e9639eae2 100644
--- a/mysql-test/suite/innodb/t/online_table_rebuild.test
+++ b/mysql-test/suite/innodb/t/online_table_rebuild.test
@@ -59,5 +59,29 @@ connection default;
reap;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-30183 Assertion `!memcmp(rec_trx_id, old_pk_trx_id->data,
+--echo # 6 + 7)' failed in row_log_table_apply_update
+--echo #
+set @old_sql_mode = @@sql_mode;
+set @@sql_mode="";
+CREATE TABLE t1(col_int int, col_varchar varchar(500))ENGINE=InnoDB;
+INSERT INTO t1(col_int) values(2560);
+set debug_sync="row_log_table_apply1_before SIGNAL con1_begin WAIT_FOR con1_commit";
+send ALTER TABLE t1 ADD PRIMARY KEY ( col_varchar);
+
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR con1_begin";
+UPDATE t1 SET col_int = 2178;
+INSERT INTO t1(col_int) VALUES(3016);
+UPDATE t1 set col_int=2802;
+SET DEBUG_SYNC="now SIGNAL con1_commit";
+
+connection default;
+--error ER_DUP_ENTRY
+reap;
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
disconnect con1;
SET DEBUG_SYNC=reset;
diff --git a/mysql-test/suite/innodb/t/undo_truncate.opt b/mysql-test/suite/innodb/t/undo_truncate.opt
index 1459ec5db74..5e331e832fd 100644
--- a/mysql-test/suite/innodb/t/undo_truncate.opt
+++ b/mysql-test/suite/innodb/t/undo_truncate.opt
@@ -1,2 +1,3 @@
--innodb-buffer-pool-size=24M
--innodb-immediate-scrub-data-uncompressed=ON
+--loose-innodb-sys-tablespaces
diff --git a/mysql-test/suite/innodb/t/undo_truncate.test b/mysql-test/suite/innodb/t/undo_truncate.test
index a5e0a52f798..eeffb6622c1 100644
--- a/mysql-test/suite/innodb/t/undo_truncate.test
+++ b/mysql-test/suite/innodb/t/undo_truncate.test
@@ -19,6 +19,9 @@ let $restart_parameters="--innodb_undo_tablespaces=2";
SET GLOBAL innodb_undo_log_truncate = 0;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+LET $MYSQLD_DATADIR = `select @@datadir`;
+LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
+--source suite/innodb/include/show_i_s_tablespaces.inc
#-----------------------------------------------------------------------------
#
# Perform DML action using multiple clients and multiple undo tablespace.
diff --git a/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff b/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff
index 0ba8a299ab9..c901bf6dbe0 100644
--- a/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff
+++ b/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff
@@ -7,7 +7,7 @@
# Test 3) Query some information_shema tables that are dependent upon
# the page size.
SELECT t.name table_name, t.n_cols, t.flag table_flags,
-@@ -36,13 +36,13 @@
+@@ -36,7 +36,7 @@
table_name n_cols table_flags index_name root_page type n_fields merge_threshold
test/t1 5 0 PRIMARY 3 3 1 50
test/t2 5 1 PRIMARY 3 3 1 50
@@ -16,6 +16,8 @@
test/t4 5 33 PRIMARY 3 3 1 50
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+@@ -45,7 +45,7 @@
+ innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t1 DEFAULT DEFAULT MYSQLD_DATADIR/test/t1.ibd
test/t2 DEFAULT DEFAULT MYSQLD_DATADIR/test/t2.ibd
-test/t3 DEFAULT 8192 MYSQLD_DATADIR/test/t3.ibd
@@ -23,7 +25,7 @@
test/t4 DEFAULT DEFAULT MYSQLD_DATADIR/test/t4.ibd
innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1
DROP TABLE t1, t2, t3, t4;
-@@ -52,141 +52,90 @@
+@@ -55,141 +55,90 @@
SET SESSION innodb_strict_mode = ON;
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
@@ -211,7 +213,7 @@
ALTER TABLE t1 KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
Level Code Message
-@@ -218,15 +167,21 @@
+@@ -221,15 +170,21 @@
DROP TABLE t1;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
@@ -233,7 +235,7 @@
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
table_name row_format create_options
-@@ -272,6 +227,7 @@
+@@ -275,6 +230,7 @@
ERROR HY000: Can't create table `test`.`t4` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
@@ -241,7 +243,7 @@
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table `test`.`t4` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
-@@ -279,107 +235,13 @@
+@@ -282,107 +238,13 @@
ERROR HY000: Can't create table `test`.`t5` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
@@ -350,7 +352,7 @@
# Test 8) Test creating a table that could lead to undo log overflow.
CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,
h blob,i blob,j blob,k blob,l blob,m blob,n blob,
-@@ -394,10 +256,6 @@
+@@ -397,10 +259,6 @@
UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b,
k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b;
CREATE INDEX t1a ON t1 (a(767));
@@ -361,7 +363,7 @@
UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c,
k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c;
CREATE INDEX t1f ON t1 (f(767));
-@@ -412,37 +270,15 @@
+@@ -415,37 +273,15 @@
COMMIT;
CREATE INDEX t1g ON t1 (g(767));
UPDATE t1 SET g=@e;
@@ -403,7 +405,7 @@
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
-@@ -468,28 +304,12 @@
+@@ -471,28 +307,12 @@
`t` blob DEFAULT NULL,
`u` blob DEFAULT NULL,
KEY `t1a` (`a`(767)),
@@ -434,7 +436,7 @@
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC
DROP TABLE t1;
# Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE
-@@ -574,27 +394,25 @@
+@@ -577,27 +397,25 @@
DROP TABLE t1;
CREATE TABLE t1(
c text NOT NULL, d text NOT NULL,
diff --git a/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff b/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff
index 0d215684e2f..90b2a1f7c48 100644
--- a/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff
+++ b/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff
@@ -7,7 +7,7 @@
# Test 3) Query some information_shema tables that are dependent upon
# the page size.
SELECT t.name table_name, t.n_cols, t.flag table_flags,
-@@ -36,13 +36,13 @@
+@@ -36,7 +36,7 @@
table_name n_cols table_flags index_name root_page type n_fields merge_threshold
test/t1 5 0 PRIMARY 3 3 1 50
test/t2 5 1 PRIMARY 3 3 1 50
@@ -16,6 +16,8 @@
test/t4 5 33 PRIMARY 3 3 1 50
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+@@ -45,7 +45,7 @@
+ innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t1 DEFAULT DEFAULT MYSQLD_DATADIR/test/t1.ibd
test/t2 DEFAULT DEFAULT MYSQLD_DATADIR/test/t2.ibd
-test/t3 DEFAULT 8192 MYSQLD_DATADIR/test/t3.ibd
@@ -23,7 +25,7 @@
test/t4 DEFAULT DEFAULT MYSQLD_DATADIR/test/t4.ibd
innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1
DROP TABLE t1, t2, t3, t4;
-@@ -54,133 +54,97 @@
+@@ -57,133 +57,97 @@
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
@@ -199,7 +201,7 @@
SHOW WARNINGS;
Level Code Message
SELECT table_name, row_format, create_options
-@@ -218,8 +182,11 @@
+@@ -221,8 +185,11 @@
DROP TABLE t1;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
@@ -211,7 +213,7 @@
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
table_name row_format create_options
-@@ -279,107 +246,13 @@
+@@ -282,107 +249,13 @@
ERROR HY000: Can't create table `test`.`t5` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
@@ -320,7 +322,7 @@
# Test 8) Test creating a table that could lead to undo log overflow.
CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,
h blob,i blob,j blob,k blob,l blob,m blob,n blob,
-@@ -394,10 +267,6 @@
+@@ -397,10 +270,6 @@
UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b,
k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b;
CREATE INDEX t1a ON t1 (a(767));
@@ -331,7 +333,7 @@
UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c,
k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c;
CREATE INDEX t1f ON t1 (f(767));
-@@ -412,30 +281,6 @@
+@@ -415,30 +284,6 @@
COMMIT;
CREATE INDEX t1g ON t1 (g(767));
UPDATE t1 SET g=@e;
@@ -362,7 +364,7 @@
CREATE INDEX t1t ON t1 (t(767));
BEGIN;
UPDATE t1 SET t=@e;
-@@ -468,24 +313,8 @@
+@@ -471,24 +316,8 @@
`t` blob DEFAULT NULL,
`u` blob DEFAULT NULL,
KEY `t1a` (`a`(767)),
@@ -387,7 +389,7 @@
KEY `t1t` (`t`(767)),
KEY `t1u` (`u`(767)),
KEY `t1ut` (`u`(767),`t`(767)),
-@@ -577,14 +406,14 @@
+@@ -580,14 +409,14 @@
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
Warnings:
@@ -404,7 +406,7 @@
DROP TABLE t1;
CREATE TABLE t1(
c text NOT NULL, d text NOT NULL,
-@@ -594,7 +423,7 @@
+@@ -597,7 +426,7 @@
CREATE TABLE t1(c text, PRIMARY KEY (c(440)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
Warnings:
diff --git a/mysql-test/suite/innodb_zip/r/page_size.result b/mysql-test/suite/innodb_zip/r/page_size.result
index 71e8e5461d3..c8d405e912a 100644
--- a/mysql-test/suite/innodb_zip/r/page_size.result
+++ b/mysql-test/suite/innodb_zip/r/page_size.result
@@ -40,6 +40,9 @@ test/t3 5 41 PRIMARY 3 3 1 50
test/t4 5 33 PRIMARY 3 3 1 50
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t1 DEFAULT DEFAULT MYSQLD_DATADIR/test/t1.ibd
test/t2 DEFAULT DEFAULT MYSQLD_DATADIR/test/t2.ibd
test/t3 DEFAULT 8192 MYSQLD_DATADIR/test/t3.ibd
diff --git a/mysql-test/suite/innodb_zip/r/restart.result b/mysql-test/suite/innodb_zip/r/restart.result
index b57fe1e89e6..133cf020d55 100644
--- a/mysql-test/suite/innodb_zip/r/restart.result
+++ b/mysql-test/suite/innodb_zip/r/restart.result
@@ -210,6 +210,9 @@ test/t7_restart#p#p1#sp#s2 test/t7_restart#p#p1#sp#s2 97 8 Dynamic 0
test/t7_restart#p#p1#sp#s3 test/t7_restart#p#p1#sp#s3 97 8 Dynamic 0
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t1_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t1_restart.ibd
test/t2_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t2_restart.ibd
test/t3_restart DEFAULT 2048 MYSQLD_DATADIR/test/t3_restart.ibd
@@ -393,6 +396,9 @@ test/t7_restart#p#p1#sp#s2 test/t7_restart#p#p1#sp#s2 97 8 Dynamic 0
test/t7_restart#p#p1#sp#s3 test/t7_restart#p#p1#sp#s3 97 8 Dynamic 0
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t1_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t1_restart.ibd
test/t2_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t2_restart.ibd
test/t3_restart DEFAULT 2048 MYSQLD_DATADIR/test/t3_restart.ibd
@@ -417,6 +423,9 @@ ALTER TABLE t6_restart TRUNCATE PARTITION p2;
ALTER TABLE t7_restart TRUNCATE PARTITION p1;
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd
test/t6_restart#p#p0 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t6_restart#p#p0.ibd
test/t6_restart#p#p1 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t6_restart#p#p1.ibd
@@ -520,6 +529,9 @@ t7_restart#p#p1#sp#s3.ibd
# restart
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd
test/t6_restart#p#p0 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t6_restart#p#p0.ibd
test/t6_restart#p#p1 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t6_restart#p#p1.ibd
@@ -622,6 +634,9 @@ RENAME TABLE t6_restart TO t66_restart;
RENAME TABLE t7_restart TO t77_restart;
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd
test/t66_restart#p#p0 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t66_restart#p#p0.ibd
test/t66_restart#p#p1 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t66_restart#p#p1.ibd
@@ -718,6 +733,9 @@ t77_restart#p#p1#sp#s3.ibd
# restart
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd
test/t66_restart#p#p0 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t66_restart#p#p0.ibd
test/t66_restart#p#p1 DEFAULT 2048 MYSQL_TMP_DIR/alt_dir/test/t66_restart#p#p1.ibd
@@ -853,6 +871,9 @@ t77_restart#p#p1#sp#s3.ibd
# restart
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd
test/t66_restart#p#p0 DEFAULT 2048 MYSQL_TMP_DIR/new_dir/test/t66_restart#p#p0.ibd
test/t66_restart#p#p1 DEFAULT 2048 MYSQL_TMP_DIR/new_dir/test/t66_restart#p#p1.ibd
@@ -992,6 +1013,9 @@ t77_restart.par
# restart
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Path
+innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
+innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
+innodb_undo003 DEFAULT DEFAULT MYSQLD_DATADIR//undo003
test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd
test/t66_restart#p#p0 DEFAULT 2048 MYSQLD_DATADIR/test/t66_restart#p#p0.ibd
test/t66_restart#p#p1 DEFAULT 2048 MYSQLD_DATADIR/test/t66_restart#p#p1.ibd
diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result
index 900348d8a13..ed385f86a31 100644
--- a/mysql-test/suite/json/r/json_table.result
+++ b/mysql-test/suite/json/r/json_table.result
@@ -1146,3 +1146,104 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
#
# End of 10.9 tests
#
+#
+# MDEV-29390: Improve coverage for UPDATE and DELETE statements in MTR test suites
+#
+# Multi-update with JSON_TABLE
+create table t1 ( name varchar(10),
+color varchar(10),
+price decimal(8,2),
+instock BOOLEAN);
+insert into t1 values ("Laptop", "black", 20000, 1);
+insert into t1 values ("Jacket", "brown", 5000, 1);
+insert into t1 values ("Jeans", "blue", 5000, 1);
+select * from t1;
+name color price instock
+Laptop black 20000.00 1
+Jacket brown 5000.00 1
+Jeans blue 5000.00 1
+set @json='
+[
+ {"name":"Laptop", "color":"black", "price":"1000", "ordered":"3"},
+ {"name":"Jeans", "color":"blue", "ordered":"0"},
+ {"name":"Phone", "color":"red", "ordered":"0"}
+]';
+select * from json_table(@json, '$[*]'
+columns(
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered' )
+) as jt;
+name color price ordered
+Laptop black 1000.00 3
+Jeans blue NULL 0
+Phone red NULL 0
+explain update t1, JSON_TABLE(@json,'$[*]'
+COLUMNS (
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered'
+ )) AS jt1
+SET t1.instock=0 where t1.name=jt1.name and jt1.ordered=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE jt1 ALL NULL NULL NULL NULL 40 Table function: json_table; Using where
+update t1, JSON_TABLE(@json,'$[*]'
+COLUMNS (
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered'
+ )) AS jt1
+SET t1.instock=0 where t1.name=jt1.name and jt1.ordered=2;
+select * from t1;
+name color price instock
+Laptop black 20000.00 1
+Jacket brown 5000.00 1
+Jeans blue 5000.00 1
+explain update t1
+SET t1.instock=2 where t1.name in (
+select jt1.name from json_table(@json, '$[*]'
+columns(
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered' )
+) as jt1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY jt1 ALL NULL NULL NULL NULL 40 Table function: json_table; Using where; FirstMatch(t1)
+update t1
+SET t1.instock=2 where t1.name in (
+select jt1.name from json_table(@json, '$[*]'
+columns(
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered' )
+) as jt1);
+select * from t1;
+name color price instock
+Laptop black 20000.00 2
+Jacket brown 5000.00 1
+Jeans blue 5000.00 2
+update t1, JSON_TABLE(@json,'$[*]'
+COLUMNS (
+name varchar(10) path '$.name',
+color varchar(10) path '$.color',
+price decimal(8,2) path '$.price',
+ordered boolean path '$.ordered'
+ )) AS jt1
+SET t1.instock=0, jt1.ordered=1 where t1.name=jt1.name;
+ERROR HY000: The target table jt1 of the UPDATE is not updatable
+select * from t1;
+name color price instock
+Laptop black 20000.00 2
+Jacket brown 5000.00 1
+Jeans blue 5000.00 2
+drop table t1;
+#
+# End of 11.0 tests
+#
diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test
index 982922ff595..5a8fe984c79 100644
--- a/mysql-test/suite/json/t/json_table.test
+++ b/mysql-test/suite/json/t/json_table.test
@@ -997,3 +997,97 @@ COLUMNS
--echo #
--echo # End of 10.9 tests
--echo #
+
+--echo #
+--echo # MDEV-29390: Improve coverage for UPDATE and DELETE statements in MTR test suites
+--echo #
+
+--echo # Multi-update with JSON_TABLE
+
+create table t1 ( name varchar(10),
+ color varchar(10),
+ price decimal(8,2),
+ instock BOOLEAN);
+
+insert into t1 values ("Laptop", "black", 20000, 1);
+insert into t1 values ("Jacket", "brown", 5000, 1);
+insert into t1 values ("Jeans", "blue", 5000, 1);
+
+select * from t1;
+
+set @json='
+[
+ {"name":"Laptop", "color":"black", "price":"1000", "ordered":"3"},
+ {"name":"Jeans", "color":"blue", "ordered":"0"},
+ {"name":"Phone", "color":"red", "ordered":"0"}
+]';
+
+select * from json_table(@json, '$[*]'
+ columns(
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered' )
+) as jt;
+
+explain update t1, JSON_TABLE(@json,'$[*]'
+ COLUMNS (
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered'
+ )) AS jt1
+ SET t1.instock=0 where t1.name=jt1.name and jt1.ordered=3;
+
+update t1, JSON_TABLE(@json,'$[*]'
+ COLUMNS (
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered'
+ )) AS jt1
+ SET t1.instock=0 where t1.name=jt1.name and jt1.ordered=2;
+
+select * from t1;
+
+explain update t1
+ SET t1.instock=2 where t1.name in (
+ select jt1.name from json_table(@json, '$[*]'
+ columns(
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered' )
+ ) as jt1);
+
+
+update t1
+ SET t1.instock=2 where t1.name in (
+ select jt1.name from json_table(@json, '$[*]'
+ columns(
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered' )
+ ) as jt1);
+
+select * from t1;
+
+
+-- error ER_NON_UPDATABLE_TABLE
+update t1, JSON_TABLE(@json,'$[*]'
+ COLUMNS (
+ name varchar(10) path '$.name',
+ color varchar(10) path '$.color',
+ price decimal(8,2) path '$.price',
+ ordered boolean path '$.ordered'
+ )) AS jt1
+ SET t1.instock=0, jt1.ordered=1 where t1.name=jt1.name;
+
+select * from t1;
+
+drop table t1;
+
+--echo #
+--echo # End of 11.0 tests
+--echo #
diff --git a/mysql-test/suite/parts/t/engine_defined_part_attributes.test b/mysql-test/suite/parts/t/engine_defined_part_attributes.test
index 22aec9286e9..1245066300c 100644
--- a/mysql-test/suite/parts/t/engine_defined_part_attributes.test
+++ b/mysql-test/suite/parts/t/engine_defined_part_attributes.test
@@ -181,16 +181,19 @@ CREATE TABLE `t12` (
(
pt1 PAGE_COMPRESSED=0
);
+--sorted_result
SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%';
ALTER TABLE `t12` ADD PARTITION (
PARTITION pt2 PAGE_COMPRESSED=1
);
+--sorted_result
SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%';
ALTER TABLE `t12` ADD PARTITION (
PARTITION pt3 PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3
);
+--sorted_result
SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%';
DROP TABLE `t12`;
@@ -203,6 +206,7 @@ CREATE TABLE `t13` (
PARTITION pt3 VALUES LESS THAN MAXVALUE
);
SHOW CREATE TABLE `t13`;
+--sorted_result
SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%';
ALTER TABLE `t13` PARTITION BY RANGE(id) (
@@ -211,6 +215,7 @@ ALTER TABLE `t13` PARTITION BY RANGE(id) (
PARTITION pt3 VALUES LESS THAN MAXVALUE PAGE_COMPRESSED=0
);
SHOW CREATE TABLE `t13`;
+--sorted_result
SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%';
DROP TABLE `t13`;
diff --git a/mysql-test/suite/period/r/update.result b/mysql-test/suite/period/r/update.result
index f726b4c07cf..004b9976f51 100644
--- a/mysql-test/suite/period/r/update.result
+++ b/mysql-test/suite/period/r/update.result
@@ -229,8 +229,8 @@ update t for portion of apptime from @s to g() set t.id= t.id + 5;
ERROR HY000: Expression in FOR PORTION OF must be constant
# success
update t for portion of apptime from @s to h() set t.id= t.id + 5;
-# select value is cached
update t for portion of apptime from (select s from t2 limit 1) to h() set t.id= t.id + 5;
+ERROR HY000: Expression in FOR PORTION OF must be constant
# auto_inrement field is updated
create or replace table t (id int primary key auto_increment, x int,
s date, e date, period for apptime(s, e));
diff --git a/mysql-test/suite/period/t/update.test b/mysql-test/suite/period/t/update.test
index 3f4dd2bdc68..fd67dc328c1 100644
--- a/mysql-test/suite/period/t/update.test
+++ b/mysql-test/suite/period/t/update.test
@@ -123,7 +123,7 @@ update t for portion of apptime from @s to g() set t.id= t.id + 5;
--echo # success
update t for portion of apptime from @s to h() set t.id= t.id + 5;
---echo # select value is cached
+--error ER_NOT_CONSTANT_EXPRESSION
update t for portion of apptime from (select s from t2 limit 1) to h() set t.id= t.id + 5;
--echo # auto_inrement field is updated
diff --git a/mysql-test/suite/plugins/r/locales.result b/mysql-test/suite/plugins/r/locales.result
index e906d27c21e..a6848fb8486 100644
--- a/mysql-test/suite/plugins/r/locales.result
+++ b/mysql-test/suite/plugins/r/locales.result
@@ -112,6 +112,7 @@ ID NAME DESCRIPTION MAX_MONTH_NAME_LENGTH MAX_DAY_NAME_LENGTH DECIMAL_POINT THOU
108 zh_HK Chinese - Hong Kong SAR 3 3 . , english
109 el_GR Greek - Greece 11 9 , . greek
110 rm_CH Romansh - Switzerland 9 9 , ' english
+111 ka_GE Georgian - Georgia 10 9 , georgian
show locales;
Id Name Description Error_Message_Language
0 en_US English - United States english
@@ -225,6 +226,7 @@ Id Name Description Error_Message_Language
108 zh_HK Chinese - Hong Kong SAR english
109 el_GR Greek - Greece greek
110 rm_CH Romansh - Switzerland english
+111 ka_GE Georgian - Georgia georgian
show locales like '%spanish%';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'like '%spanish%'' at line 1
show locales where description like '%spanish%';
diff --git a/mysql-test/suite/sys_vars/r/lc_time_names_basic.result b/mysql-test/suite/sys_vars/r/lc_time_names_basic.result
index 7d98f44f27b..c1896a0cd73 100644
--- a/mysql-test/suite/sys_vars/r/lc_time_names_basic.result
+++ b/mysql-test/suite/sys_vars/r/lc_time_names_basic.result
@@ -1024,7 +1024,11 @@ SELECT @@lc_time_names;
@@lc_time_names
rm_CH
SET @@lc_time_names = 111;
-ERROR HY000: Unknown locale: '111'
+SELECT @@lc_time_names;
+@@lc_time_names
+ka_GE
+SET @@lc_time_names = 112;
+ERROR HY000: Unknown locale: '112'
'#--------------------FN_DYNVARS_060_10-------------------------#'
SET @@lc_time_names = en_EN;
ERROR HY000: Unknown locale: 'en_EN'
diff --git a/mysql-test/suite/sys_vars/t/lc_time_names_basic.test b/mysql-test/suite/sys_vars/t/lc_time_names_basic.test
index 7f748bec2c0..7e634eda996 100644
--- a/mysql-test/suite/sys_vars/t/lc_time_names_basic.test
+++ b/mysql-test/suite/sys_vars/t/lc_time_names_basic.test
@@ -621,8 +621,10 @@ SET @@lc_time_names = 109;
SELECT @@lc_time_names;
SET @@lc_time_names = 110;
SELECT @@lc_time_names;
---Error ER_UNKNOWN_LOCALE
SET @@lc_time_names = 111;
+SELECT @@lc_time_names;
+--Error ER_UNKNOWN_LOCALE
+SET @@lc_time_names = 112;
--echo '#--------------------FN_DYNVARS_060_10-------------------------#'
#############################################################################
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 138b4697f97..73d767377b4 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -176,6 +176,12 @@ my_bool my_init(void)
mysql_stdin= & instrumented_stdin;
my_progname_short= "unknown";
+ /* Initialize our mutex handling */
+ my_mutex_init();
+
+ if (my_thread_global_init())
+ return 1;
+
if (my_progname)
{
char link_name[FN_REFLEN];
@@ -198,12 +204,6 @@ my_bool my_init(void)
}
}
- /* Initialize our mutex handling */
- my_mutex_init();
-
- if (my_thread_global_init())
- return 1;
-
#if defined(SAFEMALLOC) && !defined(DBUG_OFF)
dbug_sanity= sf_sanity;
#endif
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index e7833992f0d..a07f67a179f 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -54,10 +54,8 @@ int my_readlink(char *to, const char *filename, myf MyFlags)
if ((length=readlink(filename, to, FN_REFLEN-1)) < 0)
{
- if (my_thread_var)
- my_errno= errno;
/* Don't give an error if this wasn't a symlink */
- if (errno == EINVAL)
+ if ((my_errno=errno) == EINVAL)
{
result= 1;
strnmov(to, filename, FN_REFLEN);
diff --git a/plugin/cracklib_password_check/cracklib_password_check.c b/plugin/cracklib_password_check/cracklib_password_check.c
index 9568f84a03b..1aaf6ba0693 100644
--- a/plugin/cracklib_password_check/cracklib_password_check.c
+++ b/plugin/cracklib_password_check/cracklib_password_check.c
@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#include <my_global.h>
+#include <my_alloca.h>
#include <mysql/plugin_password_validation.h>
#include <crack.h>
#include <string.h>
diff --git a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
index 9863602af7a..f6bbe9004c2 100644
--- a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
+++ b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
@@ -6,7 +6,7 @@
* See COPYRIGHT.txt for details.
*/
-#include <my_global.h>
+#include <my_alloca.h>
#include <netinet/in.h>
#include <errno.h>
#include <poll.h>
@@ -17,9 +17,6 @@
#if __linux__
#include <sys/epoll.h>
#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
#include "hstcpsvr_worker.hpp"
#include "string_buffer.hpp"
diff --git a/plugin/handler_socket/libhsclient/allocator.hpp b/plugin/handler_socket/libhsclient/allocator.hpp
index dd3a28ba7bd..9df6a1ab752 100644
--- a/plugin/handler_socket/libhsclient/allocator.hpp
+++ b/plugin/handler_socket/libhsclient/allocator.hpp
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
+#include <my_alloca.h>
#if 0
extern "C" {
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 6895c458e4a..5fc60567e11 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -17,7 +17,7 @@
# This scripts creates the MariaDB Server system tables
#
-# All unrecognized arguments to this script are passed to mysqld.
+# All unrecognized arguments to this script are passed to mariadbd.
basedir=""
builddir=""
@@ -33,6 +33,7 @@ mysqld_opt=""
user=""
group=""
silent_startup="--silent-startup"
+log_error=""
force=0
in_rpm=0
@@ -328,9 +329,9 @@ then
exit 1
fi
-# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
+# Now we can get arguments from the groups [mariadbd] and [mysql_install_db]
# in the my.cfg file, then re-run to merge with command line arguments.
-parse_arguments `"$print_defaults" $defaults $defaults_group_suffix --mysqld mysql_install_db mariadb-install-db`
+parse_arguments `"$print_defaults" $defaults $defaults_group_suffix --mariadbd mysql_install_db mariadb-install-db`
parse_arguments PICK-ARGS-FROM-ARGV "$@"
@@ -533,7 +534,7 @@ then
args="$args --user=$user"
fi
-#To be enabled if/when we enable --group as an option to mysqld
+#To be enabled if/when we enable --group as an option to mariadbd
#if test -n "$group"
#then
# args="$args --group=$group"
@@ -556,7 +557,18 @@ else
filter_cmd_line="cat"
fi
-# Configure mysqld command line
+# Disable log error if the user don't have write access to the directory.
+# This is common when a user tries to install a personal mariadbd server
+if test -n $log_error
+then
+ if test ! -w $log_error
+ then
+ log_error=""
+ args="$args --skip-log-error"
+ fi
+fi
+
+# Configure mariadbd command line
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line()
{
@@ -599,7 +611,7 @@ cat_sql()
fi
}
-# Create the system and help tables by passing them to "mysqld --bootstrap"
+# Create the system and help tables by passing them to "mariadbd --bootstrap"
s_echo "Installing MariaDB/MySQL system tables in '$ldata' ..."
if cat_sql | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
then
diff --git a/sql/derror.cc b/sql/derror.cc
index 187d5bc20d2..455e57fd2d7 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -258,7 +258,7 @@ static File open_error_msg_file(const char *file_name, const char *language,
goto err;
error_pos=2;
if (head[0] != (uchar) 254 || head[1] != (uchar) 254 ||
- head[2] != 2 || head[3] != 4)
+ head[2] != 2 || head[3] != 5)
goto err; /* purecov: inspected */
ret->text_length= uint4korr(head+6);
diff --git a/sql/field.h b/sql/field.h
index 13d80099124..d4b59a88f59 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -5377,7 +5377,7 @@ public:
bool sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root);
bool prepare_stage1(THD *thd, MEM_ROOT *mem_root,
- handler *file, ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes *derived_attr);
void prepare_stage1_simple(CHARSET_INFO *cs)
{
@@ -5385,11 +5385,9 @@ public:
create_length_to_internal_length_simple();
}
bool prepare_stage1_typelib(THD *thd, MEM_ROOT *mem_root,
- handler *file, ulonglong table_flags);
- bool prepare_stage1_string(THD *thd, MEM_ROOT *mem_root,
- handler *file, ulonglong table_flags);
- bool prepare_stage1_bit(THD *thd, MEM_ROOT *mem_root,
- handler *file, ulonglong table_flags);
+ column_definition_type_t deftype);
+ bool prepare_stage1_string(THD *thd, MEM_ROOT *mem_root);
+ bool prepare_stage1_bit(THD *thd, MEM_ROOT *mem_root);
bool bulk_alter(const Column_derived_attributes *derived_attr,
const Column_bulk_alter_attributes *bulk_attr)
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index fdb4726a930..7c04ed845d6 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -4698,8 +4698,8 @@ exit:
part_share->next_auto_inc_val if needed.
(not to be used if auto_increment on secondary field in a multi-column
index)
- mysql_update does not set table->next_number_field, so we use
- table->found_next_number_field instead.
+ Sql_cmd_update::update_single_table() does not set table->next_number_field,
+ so we use table->found_next_number_field instead.
Also checking that the field is marked in the write set.
*/
if (table->found_next_number_field &&
@@ -4812,7 +4812,7 @@ int ha_partition::delete_row(const uchar *buf)
Called from item_sum.cc by Item_func_group_concat::clear(),
Item_sum_count::clear(), and Item_func_group_concat::clear().
- Called from sql_delete.cc by mysql_delete().
+ Called from sql_delete.cc by Sql_cmd_delete::delete_single_table().
Called from sql_select.cc by JOIN::reset().
Called from sql_union.cc by st_select_lex_unit::exec().
*/
@@ -10784,13 +10784,6 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
DBUG_RETURN(0);
}
- /*
- In Innodb we compare with either primary key value or global DB_ROW_ID so
- it is not possible that the two references are equal and are in different
- partitions, but in myisam it is possible since we are comparing offsets.
- Remove this assert if DB_ROW_ID is changed to be per partition.
- */
- DBUG_ASSERT(!m_innodb);
DBUG_RETURN(diff2 > diff1 ? -1 : 1);
}
diff --git a/sql/handler.h b/sql/handler.h
index 0810d1a503a..464c4a32651 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -248,7 +248,7 @@ enum chf_create_flags {
Example:
UPDATE a=1 WHERE pk IN (<keys>)
- mysql_update()
+ Sql_cmd_update::update_single_table()
{
if (<conditions for starting read removal>)
start_read_removal()
@@ -1807,7 +1807,8 @@ struct THD_TRANS
modified non-transactional tables of top-level statements. At
the end of the previous statement and at the beginning of the session,
it is reset to FALSE. If such functions
- as mysql_insert, mysql_update, mysql_delete etc modify a
+ as mysql_insert(), Sql_cmd_update::update_single_table,
+ Sql_cmd_delete::delete_single_table modify a
non-transactional table, they set this flag to TRUE. At the
end of the statement, the value of stmt.modified_non_trans_table
is merged with all.modified_non_trans_table and gets reset.
diff --git a/sql/item.h b/sql/item.h
index 0bbe65e4239..5956b810d51 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2687,18 +2687,27 @@ public:
void register_in(THD *thd);
bool depends_only_on(table_map view_map)
- { return marker & MARKER_FULL_EXTRACTION; }
- int get_extraction_flag() const
- { return marker & MARKER_EXTRACTION_MASK; }
+ { return get_extraction_flag() & MARKER_FULL_EXTRACTION; }
+ int get_extraction_flag() const
+ {
+ if (basic_const_item())
+ return MARKER_FULL_EXTRACTION;
+ else
+ return marker & MARKER_EXTRACTION_MASK;
+ }
void set_extraction_flag(int16 flags)
{
- marker &= ~MARKER_EXTRACTION_MASK;
- marker|= flags;
+ if (!basic_const_item())
+ {
+ marker= marker & ~MARKER_EXTRACTION_MASK;
+ marker|= flags;
+ }
}
void clear_extraction_flag()
{
- marker &= ~MARKER_EXTRACTION_MASK;
- }
+ if (!basic_const_item())
+ marker= marker & ~MARKER_EXTRACTION_MASK;
+ }
void check_pushable_cond(Pushdown_checker excl_dep_func, uchar *arg);
bool pushable_cond_checker_for_derived(uchar *arg)
{
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 80228917210..9e6c205ca76 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -2953,7 +2953,9 @@ bool Item_exists_subselect::select_prepare_to_be_in()
if (!optimizer &&
(thd->lex->sql_command == SQLCOM_SELECT ||
thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
- thd->lex->sql_command == SQLCOM_DELETE_MULTI) &&
+ thd->lex->sql_command == SQLCOM_DELETE_MULTI ||
+ thd->lex->sql_command == SQLCOM_UPDATE ||
+ thd->lex->sql_command == SQLCOM_DELETE) &&
!unit->first_select()->is_part_of_union() &&
optimizer_flag(thd, OPTIMIZER_SWITCH_EXISTS_TO_IN) &&
(is_top_level_item() ||
diff --git a/sql/json_table.cc b/sql/json_table.cc
index d404a54bc3f..ded221269ad 100644
--- a/sql/json_table.cc
+++ b/sql/json_table.cc
@@ -792,8 +792,9 @@ bool Create_json_table::add_json_table_fields(THD *thd, TABLE *table,
*/
sql_f->length= sql_f->char_length;
- if (sql_f->prepare_stage1(thd, thd->mem_root, table->file,
- table->file->ha_table_flags(), &da))
+ if (sql_f->prepare_stage1(thd, thd->mem_root,
+ COLUMN_DEFINITION_TABLE_FIELD,
+ &da))
goto err_exit;
while ((jc2= it2++) != jc)
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 02b5770aa8c..242ddb9af19 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -11928,7 +11928,7 @@ ha_rows check_quick_select(PARAM *param, uint idx, ha_rows limit,
Skip materialized derived table/view result table from MRR check as
they aren't contain any data yet.
*/
- if (param->table->pos_in_table_list->is_non_derived())
+ if (!param->table->pos_in_table_list->is_materialized_derived())
rows= file->multi_range_read_info_const(keynr, &seq_if, (void*)&seq, 0,
bufsize, mrr_flags, limit, cost);
param->quick_rows[keynr]= rows;
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 99082813d7f..f2d536cd47b 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -741,7 +741,12 @@ void JOIN::add_keyuses_for_splitting()
if (ext_keyuses_for_splitting->push(keyuse_ext_end))
goto err;
- spl_opt_info->unsplit_card= join_record_count;
+ /*
+ Use the number of rows that was computed by
+ TABLE_LIST::fetch_number_of_rows():
+ */
+ spl_opt_info->unsplit_card=
+ rows2double(select_lex->master_unit()->derived->table->stat_records());
rec_len= table->s->rec_buff_length;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 1d0b1ff1874..9c8fc6dc0b3 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -30,6 +30,8 @@
#include "sql_base.h"
#include "sql_const.h"
#include "sql_select.h"
+#include "sql_update.h" // class Sql_cmd_update
+#include "sql_delete.h" // class Sql_cmd_delete
#include "filesort.h"
#include "opt_subselect.h"
#include "sql_test.h"
@@ -534,6 +536,48 @@ bool is_materialization_applicable(THD *thd, Item_in_subselect *in_subs,
return FALSE;
}
+/**
+ @brief Check whether an IN subquery must be excluded from conversion to SJ
+
+ @param thd global context the processed statement
+ @returns true if the IN subquery must be excluded from conversion to SJ
+
+ @note
+ Currently a top level IN subquery of an delete statement is not converted
+ to SJ if the statement contains ORDER BY ... LIMIT or contains RETURNING.
+
+ @todo
+ The disjunctive members
+ !((Sql_cmd_update *) cmd)->is_multitable()
+ !((Sql_cmd_delete *) cmd)->is_multitable()
+ will be removed when conversions of IN predicands to semi-joins are
+ fully supported for single-table UPDATE/DELETE statements.
+*/
+
+bool SELECT_LEX::is_sj_conversion_prohibited(THD *thd)
+{
+ DBUG_ASSERT(master_unit()->item->substype() == Item_subselect::IN_SUBS);
+
+ SELECT_LEX *outer_sl= outer_select();
+ if (outer_sl->outer_select())
+ return false;
+
+ Sql_cmd *cmd= thd->lex->m_sql_cmd;
+
+ switch (thd->lex->sql_command) {
+ case SQLCOM_UPDATE:
+ return
+ !((Sql_cmd_update *) cmd)->is_multitable() &&
+ ((Sql_cmd_update *) cmd)->processing_as_multitable_update_prohibited(thd);
+ case SQLCOM_DELETE:
+ return
+ !((Sql_cmd_delete *) cmd)->is_multitable() &&
+ ((Sql_cmd_delete *) cmd)->processing_as_multitable_delete_prohibited(thd);
+ default:
+ return false;
+ }
+}
+
/*
Check if we need JOIN::prepare()-phase subquery rewrites and if yes, do them
@@ -677,9 +721,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
3. Subquery does not have GROUP BY or ORDER BY
4. Subquery does not use aggregate functions or HAVING
5. Subquery predicate is at the AND-top-level of ON/WHERE clause
- 6. We are not in a subquery of a single table UPDATE/DELETE that
- doesn't have a JOIN (TODO: We should handle this at some
- point by switching to multi-table UPDATE/DELETE)
+ 6. We are not in a subquery of a single-table UPDATE/DELETE that
+ does not allow conversion to multi-table UPDATE/DELETE
7. We're not in a table-less subquery like "SELECT 1"
8. No execution method was already chosen (by a prepared statement)
9. Parent select is not a table-less select
@@ -698,7 +741,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
!select_lex->group_list.elements && !join->order && // 3
!join->having && !select_lex->with_sum_func && // 4
in_subs->emb_on_expr_nest && // 5
- select_lex->outer_select()->join && // 6
+ !select_lex->is_sj_conversion_prohibited(thd) && // 6
parent_unit->first_select()->leaf_tables.elements && // 7
!in_subs->has_strategy() && // 8
select_lex->outer_select()->table_list.first && // 9
@@ -758,7 +801,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
*/
if (in_subs && !in_subs->has_strategy())
{
- if (is_materialization_applicable(thd, in_subs, select_lex))
+ if (!select_lex->is_sj_conversion_prohibited(thd) &&
+ is_materialization_applicable(thd, in_subs, select_lex))
{
in_subs->add_strategy(SUBS_MATERIALIZATION);
diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt
index ddb813057ab..33d0bea2dbd 100644
--- a/sql/share/CMakeLists.txt
+++ b/sql/share/CMakeLists.txt
@@ -24,6 +24,7 @@ english
estonian
french
german
+georgian
greek
hindi
hungarian
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index b66bd694207..34a5dad6d3f 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -1,4 +1,4 @@
-languages bulgarian=bgn cp1251, chinese=chi gbk, czech=cze latin2, danish=dan latin1, dutch=nla latin1, english=eng latin1, estonian=est latin7, french=fre latin1, german=ger latin1, greek=greek greek, hindi=hindi utf8mb3, hungarian=hun latin2, italian=ita latin1, japanese=jpn ujis, korean=kor euckr, norwegian-ny=norwegian-ny latin1, norwegian=nor latin1, polish=pol latin2, portuguese=por latin1, romanian=rum latin2, russian=rus koi8r, serbian=serbian cp1250, slovak=slo latin2, spanish=spa latin1, swedish=swe latin1, ukrainian=ukr koi8u;
+languages bulgarian=bgn, chinese=chi, czech=cze, danish=dan, dutch=nla, english=eng, estonian=est, french=fre, georgian=geo, german=ger, greek=greek, hindi=hindi, hungarian=hun, italian=ita, japanese=jpn, korean=kor, norwegian-ny=norwegian-ny, norwegian=nor, polish=pol, portuguese=por, romanian=rum, russian=rus, serbian=serbian, slovak=slo, spanish=spa, swedish=swe, ukrainian=ukr;
default-language eng
@@ -16,6 +16,7 @@ ER_NO
est "EI"
fre "NON"
ger "Nein"
+ geo "არა"
greek "ΟΧΙ"
hindi "नहीं"
hun "NEM"
@@ -38,6 +39,7 @@ ER_YES
est "JAH"
fre "OUI"
ger "Ja"
+ geo "დიახ"
greek "ΝΑΙ"
hindi "हाँ"
hun "IGEN"
@@ -62,6 +64,7 @@ ER_CANT_CREATE_FILE
est "Ei suuda luua faili '%-.200s' (veakood: %M)"
fre "Ne peut créer le fichier '%-.200s' (Errcode: %M)"
ger "Kann Datei '%-.200s' nicht erzeugen (Fehler: %M)"
+ geo "ფაილის '%-.200s' შექმნა შეუძლებელია (შეცდომა: %M)"
greek "Αδύνατη η δημιουργία του αρχείου '%-.200s' (κωδικός λάθους: %M)"
hindi "फ़ाइल '%-.200s' नहीं बन सका (errno: %M)"
hun "A '%-.200s' file nem hozhato letre (hibakod: %M)"
@@ -88,6 +91,7 @@ ER_CANT_CREATE_TABLE
est "Ei suuda luua tabelit %`s.%`s (veakood: %M)"
fre "Ne peut créer la table %`s.%`s (Errcode: %M)"
ger "Kann Tabelle %`s.%`s nicht erzeugen (Fehler: %M)"
+ geo "შეცდომა ცხრილის (%`s.%`s) შექმნისას (შეცდ. კოდი: %M)"
greek "Αδύνατη η δημιουργία του πίνακα %`s.%`s (κωδικός λάθους: %M)"
hindi "टेबल '%`s.%`s' नहीं बन सका (errno: %M)"
hun "A %`s.%`s tabla nem hozhato letre (hibakod: %M)"
@@ -114,6 +118,7 @@ ER_CANT_CREATE_DB
est "Ei suuda luua andmebaasi '%-.192s' (veakood: %M)"
fre "Ne peut créer la base '%-.192s' (Erreur %M)"
ger "Kann Datenbank '%-.192s' nicht erzeugen (Fehler: %M)"
+ geo "მონაცემთა ბაზის ('%-.192s') შექმნა შეუძლებელია (შეცდომა: %M)"
greek "Αδύνατη η δημιουργία της βάσης δεδομένων '%-.192s' (κωδικός λάθους: %M)"
hindi "डेटाबेस '%-.192s' नहीं बन सका (errno: %M)"
hun "Az '%-.192s' adatbazis nem hozhato letre (hibakod: %M)"
@@ -140,6 +145,7 @@ ER_DB_CREATE_EXISTS
est "Ei suuda luua andmebaasi '%-.192s': andmebaas juba eksisteerib"
fre "Ne peut créer la base '%-.192s'; elle existe déjà"
ger "Kann Datenbank '%-.192s' nicht erzeugen. Datenbank existiert bereits"
+ geo "მონაცემთა ბაზის ('%-.192s') შექმნა შეუძლებელია. მონაცემთა ბაზა უკვე არსებობს"
greek "Αδύνατη η δημιουργία της βάσης δεδομένων '%-.192s'; Η βάση δεδομένων υπάρχει ήδη"
hindi "डेटाबेस '%-.192s' नहीं बन सकता है; यह डेटाबेस पहले से ही मौजूद है"
hun "Az '%-.192s' adatbazis nem hozhato letre Az adatbazis mar letezik"
@@ -166,6 +172,7 @@ ER_DB_DROP_EXISTS
est "Ei suuda kustutada andmebaasi '%-.192s': andmebaasi ei eksisteeri"
fre "Ne peut effacer la base '%-.192s'; elle n'existe pas"
ger "Kann Datenbank '%-.192s' nicht löschen; Datenbank nicht vorhanden"
+ geo "მონაცემთა ბაზის ('%-.192s') წაშლა შეუძლებელია. ასეთი მონაცემთა ბაზა არ არსებობს"
greek "Αδύνατη η διαγραφή της βάσης δεδομένων '%-.192s'. Η βάση δεδομένων δεν υπάρχει"
hindi "डेटाबेस '%-.192s' ड्रॉप नहीं कर सकते हैं; यह डेटाबेस मौजूद नहीं है"
hun "A(z) '%-.192s' adatbazis nem szuntetheto meg. Az adatbazis nem letezik"
@@ -192,6 +199,7 @@ ER_DB_DROP_DELETE
est "Viga andmebaasi kustutamisel (ei suuda kustutada faili '%-.192s', veakood: %M)"
fre "Ne peut effacer la base '%-.192s' (erreur %M)"
ger "Fehler beim Löschen der Datenbank ('%-.192s' kann nicht gelöscht werden, Fehler: %M)"
+ geo "შეცდომა მონაცემთა ბაზის წაშლისას ('%-.192s'-ის წაშლა შეუძლებელია. შეცდ. კოდი: %M)"
greek "Παρουσιάστηκε πρόβλημα κατά τη διαγραφή της βάσης δεδομένων (αδύνατη η διαγραφή '%-.192s', κωδικός λάθους: %M)"
hindi "डेटाबेस ड्रॉप में त्रुटि हुई ('%-.192s' हटा नहीं सकते, errno: %M)"
hun "Adatbazis megszuntetesi hiba ('%-.192s' nem torolheto, hibakod: %M)"
@@ -218,6 +226,7 @@ ER_DB_DROP_RMDIR
est "Viga andmebaasi kustutamisel (ei suuda kustutada kataloogi '%-.192s', veakood: %M)"
fre "Erreur en effaçant la base (rmdir '%-.192s', erreur %M)"
ger "Fehler beim Löschen der Datenbank (Verzeichnis '%-.192s' kann nicht gelöscht werden, Fehler: %M)"
+ geo "მონაცემთა ბაზის წაშლა შეუძლებელია. (ვერ წავშალე საქაღალდე '%-.192s'. შეცდ. კოდი: %M) "
greek "Παρουσιάστηκε πρόβλημα κατά τη διαγραφή της βάσης δεδομένων (αδύνατη η διαγραφή του φακέλλου '%-.192s', κωδικός λάθους: %M)"
hindi "डेटाबेस ड्रॉप में त्रुटि हुई ('%-.192s' rmdir नहीं कर सकते, errno: %M)"
hun "Adatbazis megszuntetesi hiba ('%-.192s' nem szuntetheto meg, hibakod: %M)"
@@ -244,6 +253,7 @@ ER_CANT_DELETE_FILE
est "Viga '%-.192s' kustutamisel (veakood: %M)"
fre "Erreur en effaçant '%-.192s' (Errcode: %M)"
ger "Fehler beim Löschen von '%-.192s' (Fehler: %M)"
+ geo "'%-.192s'-ის წაშლა შეუძლებელია (შეცდ. კოდი: %M)"
greek "Παρουσιάστηκε πρόβλημα κατά τη διαγραφή '%-.192s' (κωδικός λάθους: %M)"
hindi "'%-.192s' के हटाने पर त्रुटि हुई (errno: %M)"
hun "Torlesi hiba: '%-.192s' (hibakod: %M)"
@@ -270,6 +280,7 @@ ER_CANT_FIND_SYSTEM_REC
est "Ei suuda lugeda kirjet süsteemsest tabelist"
fre "Ne peut lire un enregistrement de la table 'system'"
ger "Datensatz in der Systemtabelle nicht lesbar"
+ geo "სისტემური ცხრილიდან ჩანაწერის წაკითხვა შეუძლებელია"
greek "Αδύνατη η ανάγνωση εγγραφής από πίνακα του συστήματος"
hindi "सिस्टम टेबल से रिकॉर्ड नहीं पढ़ सके"
hun "Nem olvashato rekord a rendszertablaban"
@@ -296,6 +307,7 @@ ER_CANT_GET_STAT
est "Ei suuda lugeda '%-.200s' olekut (veakood: %M)"
fre "Ne peut obtenir le status de '%-.200s' (Errcode: %M)"
ger "Kann Status von '%-.200s' nicht ermitteln (Fehler: %M)"
+ geo "'%-.200s'-ის მდგომარეობის მიღება შეუძლებელია (შეცდ.კოდი: %M)"
greek "Αδύνατη η λήψη πληροφοριών για την κατάσταση του '%-.200s' (κωδικός λάθους: %M)"
hindi "'%-.200s' की अवस्था प्राप्त नहीं कर सके (errno: %M)"
hun "A(z) '%-.200s' statusza nem allapithato meg (hibakod: %M)"
@@ -322,6 +334,7 @@ ER_CANT_GET_WD
est "Ei suuda identifitseerida jooksvat kataloogi (veakood: %M)"
fre "Ne peut obtenir le répertoire de travail (Errcode: %M)"
ger "Kann Arbeitsverzeichnis nicht ermitteln (Fehler: %M)"
+ geo "სამუშაო საქაღალდის მიღების შეცდომა (შეცდ. კოდი: %M)"
greek "Ο φάκελλος εργασίας δεν βρέθηκε (κωδικός λάθους: %M)"
hindi "Working डाइरेक्टरी प्राप्त नहीं कर सके (errno: %M)"
hun "A munkakonyvtar nem allapithato meg (hibakod: %M)"
@@ -348,6 +361,7 @@ ER_CANT_LOCK
est "Ei suuda lukustada faili (veakood: %M)"
fre "Ne peut verrouiller le fichier (Errcode: %M)"
ger "Datei kann nicht gesperrt werden (Fehler: %M)"
+ geo "ფაილის დაბლოკვა შეუძლებელია (შეცდ. კოდი: %M)"
greek "Το αρχείο δεν μπορεί να κλειδωθεί (κωδικός λάθους: %M)"
hindi "फ़ाइल लॉक नहीं कर सके (errno: %M)"
hun "A file nem zarolhato. (hibakod: %M)"
@@ -374,6 +388,7 @@ ER_CANT_OPEN_FILE
est "Ei suuda avada faili '%-.200s' (veakood: %M)"
fre "Ne peut ouvrir le fichier: '%-.200s' (Errcode: %M)"
ger "Kann Datei '%-.200s' nicht öffnen (Fehler: %M)"
+ geo "ფაილი ვერ გავხსენი: '%-.200s' (შეცდ. კოდი: %M)"
greek "Δεν είναι δυνατό να ανοιχτεί το αρχείο: '%-.200s' (κωδικός λάθους: %M)"
hindi "फ़ाइल '%-.200s' नहीं खोल सकते (errno: %M)"
hun "A '%-.200s' file nem nyithato meg (hibakod: %M)"
@@ -400,6 +415,7 @@ ER_FILE_NOT_FOUND
est "Ei suuda leida faili '%-.200s' (veakood: %M)"
fre "Ne peut trouver le fichier: '%-.200s' (Errcode: %M)"
ger "Kann Datei '%-.200s' nicht finden (Fehler: %M)"
+ geo "ფაილი ვერ ვიპოვე: '%-.200s' (შეცდ. კოდი: %M)"
greek "Δεν βρέθηκε το αρχείο: '%-.200s' (κωδικός λάθους: %M)"
hindi "फ़ाइल '%-.200s' नहीं मिला (errno: %M)"
hun "A(z) '%-.200s' file nem talalhato (hibakod: %M)"
@@ -426,6 +442,7 @@ ER_CANT_READ_DIR
est "Ei suuda lugeda kataloogi '%-.192s' (veakood: %M)"
fre "Ne peut lire le répertoire de '%-.192s' (Errcode: %M)"
ger "Verzeichnis von '%-.192s' nicht lesbar (Fehler: %M)"
+ geo "საქაღალდის ('%-.192s') წაკითხვა შეუძლებელია. (შეცდ. კოდი: %M)"
greek "Δεν είναι δυνατό να διαβαστεί ο φάκελλος του '%-.192s' (κωδικός λάθους: %M)"
hindi "'%-.192s' की डायरेक्टरी नहीं पढ़ सके (errno: %M)"
hun "A(z) '%-.192s' konyvtar nem olvashato. (hibakod: %M)"
@@ -452,6 +469,7 @@ ER_CANT_SET_WD
est "Ei suuda siseneda kataloogi '%-.192s' (veakood: %M)"
fre "Ne peut changer le répertoire pour '%-.192s' (Errcode: %M)"
ger "Kann nicht in das Verzeichnis '%-.192s' wechseln (Fehler: %M)"
+ geo "საქაღალდის '%-.192s'-ზე შეცვლა შეუძლებელია (შეცდ. კოდი: %M)"
greek "Αδύνατη η αλλαγή του τρέχοντος καταλόγου σε '%-.192s' (κωδικός λάθους: %M)"
hindi "'%-.192s' डायरेक्टरी में नहीं बदल सके (errno: %M)"
hun "Konyvtarvaltas nem lehetseges a(z) '%-.192s'-ba. (hibakod: %M)"
@@ -478,6 +496,7 @@ ER_CHECKREAD
est "Kirje tabelis '%-.192s' on muutunud viimasest lugemisest saadik"
fre "Enregistrement modifié depuis sa dernière lecture dans la table '%-.192s'"
ger "Datensatz hat sich seit dem letzten Zugriff auf Tabelle '%-.192s' geändert"
+ geo "ცხრილში '%-.192s' ჩანაწერი შეიცვალა ბოლო წაკითხვის შემდეგ"
greek "Η εγγραφή έχει αλλάξει από την τελευταία φορά που ανασύρθηκε από τον πίνακα '%-.192s'"
hindi "रिकॉर्ड टेबल '%-.192s' पिछली बार पढ़े जाने के बाद से बदल गया है"
hun "A(z) '%-.192s' tablaban talalhato rekord megvaltozott az utolso olvasas ota"
@@ -504,6 +523,7 @@ ER_DISK_FULL
est "Ketas täis (%s). Ootame kuni tekib vaba ruumi... (veakood: %M)"
fre "Disque plein (%s). J'attend que quelqu'un libère de l'espace... (Errcode: %M)"
ger "Festplatte voll (%s). Warte, bis jemand Platz schafft ... (Fehler: %M)"
+ geo "დისკი სავსეა (%s). ველოდები, სანამ ვინმე ადგილის გაათავისუფლებს... (შეცდ. კოდი: %M)"
greek "Δεν υπάρχει χώρος στο δίσκο (%s). Παρακαλώ, περιμένετε να ελευθερωθεί χώρος... (κωδικός λάθους: %M)"
hindi "डिस्क पूरी तरह से भरा हुआ है (%s); कुछ स्थान खाली करें (errno: %M)"
hun "A lemez megtelt (%s). (hibakod: %M)"
@@ -530,6 +550,7 @@ ER_DUP_KEY 23000
est "Ei saa kirjutada, korduv võti tabelis '%-.192s'"
fre "Ecriture impossible, doublon dans une clé de la table '%-.192s'"
ger "Kann nicht speichern, Grund: doppelter Schlüssel in Tabelle '%-.192s'"
+ geo "ჩაწერის შეცდომა. დუბლირებული გასაღები ცხრილში '%-.192s'"
greek "Δεν είναι δυνατή η καταχώρηση, η τιμή υπάρχει ήδη στον πίνακα '%-.192s'"
hindi "टेबल '%-.192s' में DUPLICATE KEY मौजूद होने के कारण नहीं लिख सके"
hun "Irasi hiba, duplikalt kulcs a '%-.192s' tablaban"
@@ -556,6 +577,7 @@ ER_ERROR_ON_CLOSE
est "Viga faili '%-.192s' sulgemisel (veakood: %M)"
fre "Erreur a la fermeture de '%-.192s' (Errcode: %M)"
ger "Fehler beim Schließen von '%-.192s' (Fehler: %M)"
+ geo "შეცდომა '%-.192s'-ის დახურვიას (შეცდ. კოდი: %M)"
greek "Παρουσιάστηκε πρόβλημα κλείνοντας το '%-.192s' (κωδικός λάθους: %M)"
hindi "'%-.192s' के बंद पर त्रुटि हुई (errno: %M)"
hun "Hiba a(z) '%-.192s' zarasakor. (hibakod: %M)"
@@ -582,6 +604,7 @@ ER_ERROR_ON_READ
est "Viga faili '%-.200s' lugemisel (veakood: %M)"
fre "Erreur en lecture du fichier '%-.200s' (Errcode: %M)"
ger "Fehler beim Lesen der Datei '%-.200s' (Fehler: %M)"
+ geo "შეცდომა ფაილის ('%-.200s') წაკითხვისას (შეცდ. კოდი: %M)"
greek "Πρόβλημα κατά την ανάγνωση του αρχείου '%-.200s' (κωδικός λάθους: %M)"
hindi "फ़ाइल '%-.200s' पढ़ने में त्रुटि हुई (errno: %M)"
hun "Hiba a '%-.200s'file olvasasakor. (hibakod: %M)"
@@ -608,6 +631,7 @@ ER_ERROR_ON_RENAME
est "Viga faili '%-.210s' ümbernimetamisel '%-.210s'-ks (veakood: %M)"
fre "Erreur en renommant '%-.210s' en '%-.210s' (Errcode: %M)"
ger "Fehler beim Umbenennen von '%-.210s' in '%-.210s' (Fehler: %M)"
+ geo "შეცდომა '%-.210s'-ის სახელის '%-.210s'-ზე გადარქმევისას (შეცდ. კოდი: %M)"
greek "Πρόβλημα κατά την μετονομασία του αρχείου '%-.210s' to '%-.210s' (κωδικός λάθους: %M)"
hindi "'%-.210s' का नाम '%-.210s' बदलने पर त्रुटि हुई (errno: %M)"
hun "Hiba a '%-.210s' file atnevezesekor '%-.210s'. (hibakod: %M)"
@@ -634,6 +658,7 @@ ER_ERROR_ON_WRITE
est "Viga faili '%-.200s' kirjutamisel (veakood: %M)"
fre "Erreur d'écriture du fichier '%-.200s' (Errcode: %M)"
ger "Fehler beim Speichern der Datei '%-.200s' (Fehler: %M)"
+ geo "ფაილში ('%-.200s') ჩაწერის შეცდომა. (შეცდ. კოდი: %M)"
greek "Πρόβλημα κατά την αποθήκευση του αρχείου '%-.200s' (κωδικός λάθους: %M)"
hindi "फ़ाइल '%-.200s' लिखने में त्रुटि हुई (errno: %M)"
hun "Hiba a '%-.200s' file irasakor. (hibakod: %M)"
@@ -660,6 +685,7 @@ ER_FILE_USED
est "'%-.192s' on lukustatud muudatuste vastu"
fre "'%-.192s' est verrouillé contre les modifications"
ger "'%-.192s' ist für Änderungen gesperrt"
+ geo "'%-.192s' ცვლილებებისთვის დაბლოკილია"
greek "'%-.192s' δεν επιτρέπονται αλλαγές"
hindi "फ़ाइल '%-.192s' में कोई बदलाव नहीं कर सकते"
hun "'%-.192s' a valtoztatas ellen zarolva"
@@ -686,6 +712,7 @@ ER_FILSORT_ABORT
est "Sorteerimine katkestatud"
fre "Tri alphabétique abandonné"
ger "Sortiervorgang abgebrochen"
+ geo "დალაგება გაუქმდა"
greek "Η διαδικασία ταξινόμισης ακυρώθηκε"
hindi "SORT निरस्त"
hun "Sikertelen rendezes"
@@ -712,6 +739,7 @@ ER_FORM_NOT_FOUND
est "Vaade '%-.192s' ei eksisteeri '%-.192s' jaoks"
fre "La vue (View) '%-.192s' n'existe pas pour '%-.192s'"
ger "View '%-.192s' existiert für '%-.192s' nicht"
+ geo "ხედი '%-.192s'-ი '%-.192s'-სთვის არ არსებობს"
greek "Το View '%-.192s' δεν υπάρχει για '%-.192s'"
hindi "VIEW '%-.192s', '%-.192s' के लिए मौजूद नहीं है"
hun "A(z) '%-.192s' nezet nem letezik a(z) '%-.192s'-hoz"
@@ -735,6 +763,7 @@ ER_GET_ERRNO
eng "Got error %M from storage engine %s"
fre "Reçu l'erreur %M du handler de la table %s"
ger "Fehler %M von Speicher-Engine %s"
+ geo "მივიღე შეცდომა %M საცავის ძრავიდან %s"
greek "Ελήφθη μήνυμα λάθους %M από τον χειριστή πίνακα (table handler) %s"
hindi "%M त्रुटि %s स्टोरेज इंजन से"
ita "Rilevato l'errore %M dal gestore delle tabelle %s"
@@ -752,6 +781,7 @@ ER_ILLEGAL_HA
chi "存储引擎%s %`s.%`s 表没有该选项"
eng "Storage engine %s of the table %`s.%`s doesn't have this option"
ger "Diese Option gibt es nicht in Speicher-Engine %s für %`s.%`s"
+ geo "საცავის ძრავს %s ცხრილისთვის %`s.%`s ამ პარამეტრის მხარდაჭერა არ გააჩნია"
hindi "स्टोरेज इंजन %s में यह विकल्प उपलब्ध नहीं है (टेबल: %`s.%`s)"
rus "Обработчик %s таблицы %`s.%`s не поддерживает эту возможность"
spa "El motor de almacenaje %s de la tabla %`s.%`s no contiene esta opción"
@@ -764,6 +794,7 @@ ER_KEY_NOT_FOUND
est "Ei suuda leida kirjet '%-.192s'-s"
fre "Ne peut trouver l'enregistrement dans '%-.192s'"
ger "Kann Datensatz in '%-.192s' nicht finden"
+ geo "'%-.192s'-ში ჩანაწერი ვერ ვიპოვე"
greek "Αδύνατη η ανεύρεση εγγραφής στο '%-.192s'"
hindi "'%-.192s' में रिकॉर्ड नहीं मिला"
hun "Nem talalhato a rekord '%-.192s'-ben"
@@ -790,6 +821,7 @@ ER_NOT_FORM_FILE
est "Vigane informatsioon failis '%-.200s'"
fre "Information erronnée dans le fichier: '%-.200s'"
ger "Falsche Information in Datei '%-.200s'"
+ geo "არასწორი ინფორმაცია ფაილში: '%-.200s'"
greek "Λάθος πληροφορίες στο αρχείο: '%-.200s'"
hindi "फ़ाइल '%-.200s' में गलत जानकारी है"
hun "Ervenytelen info a file-ban: '%-.200s'"
@@ -816,6 +848,7 @@ ER_NOT_KEYFILE
est "Tabeli '%-.200s' võtmefail on vigane; proovi seda parandada"
fre "Index corrompu dans la table: '%-.200s'; essayez de le réparer"
ger "Fehlerhafte Index-Datei für Tabelle '%-.200s'; versuche zu reparieren"
+ geo "ინდექსი ცხრილისთვის '%-.200s' დაზიანებულია. სცადეთ, შეაკეთოთ ის"
greek "Λάθος αρχείο ταξινόμισης (key file) για τον πίνακα: '%-.200s'; Παρακαλώ, διορθώστε το!"
hindi "टेबल '%-.200s' का इंडेक्स CORRUPT हो गया है; इसे REPAIR करने की कोशिश करें"
hun "Ervenytelen kulcsfile a tablahoz: '%-.200s'; probalja kijavitani!"
@@ -842,6 +875,7 @@ ER_OLD_KEYFILE
est "Tabeli '%-.192s' võtmefail on aegunud; paranda see!"
fre "Vieux fichier d'index pour la table '%-.192s'; réparez le!"
ger "Alte Index-Datei für Tabelle '%-.192s'. Bitte reparieren"
+ geo "ინდექსის ფაილი ცხრილისთვის '%-.200s' ძველია. შეაკეთეთ ის!"
greek "Παλαιό αρχείο ταξινόμισης (key file) για τον πίνακα '%-.192s'; Παρακαλώ, διορθώστε το!"
hindi "टेबल '%-.192s' के लिए पुरानी KEY फ़ाइल; इसे REPAIR करने की कोशिश करें"
hun "Regi kulcsfile a '%-.192s'tablahoz; probalja kijavitani!"
@@ -868,6 +902,7 @@ ER_OPEN_AS_READONLY
est "Tabel '%-.192s' on ainult lugemiseks"
fre "'%-.192s' est en lecture seulement"
ger "Tabelle '%-.192s' ist nur lesbar"
+ geo "ცხილი '%-.192s' მხოლოდ კითხვადია"
greek "'%-.192s' επιτρέπεται μόνο η ανάγνωση"
hindi "टेबल '%-.192s' READ-ONLY है"
hun "'%-.192s' irasvedett"
@@ -894,6 +929,7 @@ ER_OUTOFMEMORY HY001 S1001
est "Mälu sai otsa. Proovi MariaDB uuesti käivitada (puudu jäi %d baiti)"
fre "Manque de mémoire. Redémarrez le démon et ré-essayez (%d octets nécessaires)"
ger "Kein Speicher vorhanden (%d Bytes benötigt). Bitte Server neu starten"
+ geo "არასაკმარისი მეხსიერება. გადატვირთეთ სერვერი და კიდევ სცადეთ (მჭირდებოდა %d ბაიტი"
greek "Δεν υπάρχει διαθέσιμη μνήμη. Προσπαθήστε πάλι, επανεκινώντας τη διαδικασία (demon) (χρειάζονται %d bytes)"
hun "Nincs eleg memoria. Inditsa ujra a demont, es probalja ismet. (%d byte szukseges.)"
ita "Memoria esaurita. Fai ripartire il demone e riprova (richiesti %d bytes)"
@@ -919,6 +955,7 @@ ER_OUT_OF_SORTMEMORY HY001 S1001
est "Mälu sai sorteerimisel otsa. Suurenda MariaDB-i sorteerimispuhvrit"
fre "Manque de mémoire pour le tri. Augmentez-la"
ger "Kein Speicher zum Sortieren vorhanden. sort_buffer_size sollte im Server erhöht werden"
+ geo "არასაკმარისი მეხსიერება. გადახედეთ სერვერის დალაგების ბუფერის ზომის პარამეტრებს"
greek "Δεν υπάρχει διαθέσιμη μνήμη για ταξινόμιση. Αυξήστε το sort buffer size για τη διαδικασία (demon)"
hun "Nincs eleg memoria a rendezeshez. Novelje a rendezo demon puffermeretet"
ita "Memoria per gli ordinamenti esaurita. Incrementare il 'sort_buffer' al demone"
@@ -944,6 +981,7 @@ ER_UNEXPECTED_EOF
est "Ootamatu faililõpumärgend faili '%-.192s' lugemisel (veakood: %M)"
fre "Fin de fichier inattendue en lisant '%-.192s' (Errcode: %M)"
ger "Unerwartetes Ende beim Lesen der Datei '%-.192s' (Fehler: %M)"
+ geo "მოულოდნელი EOF ფაილის ('%-.192s') წაკითხვისას (შეცდ. კოდი: %M)"
greek "Κατά τη διάρκεια της ανάγνωσης, βρέθηκε απροσδόκητα το τέλος του αρχείου '%-.192s' (κωδικός λάθους: %M)"
hun "Varatlan filevege-jel a '%-.192s'olvasasakor. (hibakod: %M)"
ita "Fine del file inaspettata durante la lettura del file '%-.192s' (errno: %M)"
@@ -969,6 +1007,7 @@ ER_CON_COUNT_ERROR 08004
est "Liiga palju samaaegseid ühendusi"
fre "Trop de connexions"
ger "Zu viele Verbindungen"
+ geo "მეტისმეტად ბევრი მიერთება"
greek "Υπάρχουν πολλές συνδέσεις..."
hindi "अत्यधिक कनेक्शन"
hun "Tul sok kapcsolat"
@@ -995,6 +1034,7 @@ ER_OUT_OF_RESOURCES
est "Mälu sai otsa. Võimalik, et aitab swap-i lisamine või käsu 'ulimit' abil MariaDB-le rohkema mälu kasutamise lubamine"
fre "Manque de 'threads'/mémoire"
ger "Kein Speicher mehr vorhanden."
+ geo "არასაკმარისი მეხსიერება."
greek "Πρόβλημα με τη διαθέσιμη μνήμη (Out of thread space/memory)"
hun "Elfogyott a thread-memoria"
ita "Fine dello spazio/memoria per i thread"
@@ -1020,6 +1060,7 @@ ER_BAD_HOST_ERROR 08S01
est "Ei suuda lahendada IP aadressi masina nimeks"
fre "Ne peut obtenir de hostname pour votre adresse"
ger "Kann Hostnamen für diese Adresse nicht erhalten"
+ geo "თქვენი მისამართისთვის ჰოსტის სახელის მიღება შეუძლებელია"
greek "Δεν έγινε γνωστό το hostname για την address σας"
hindi "आपके I.P. ऐड्रेस के लिए होस्टनेम प्राप्त करने में विफल रहे"
hun "A gepnev nem allapithato meg a cimbol"
@@ -1046,6 +1087,7 @@ ER_HANDSHAKE_ERROR 08S01
est "Väär handshake"
fre "Mauvais 'handshake'"
ger "Ungültiger Handshake"
+ geo "არასწორი მისასალმებელი შეტყობინება"
greek "Η αναγνώριση (handshake) δεν έγινε σωστά"
hindi "संपर्क स्थापित करते समय त्रुटि हुई (BAD HANDSHAKE)"
hun "A kapcsolatfelvetel nem sikerult (Bad handshake)"
@@ -1071,6 +1113,7 @@ ER_DBACCESS_DENIED_ERROR 42000
est "Ligipääs keelatud kasutajale '%s'@'%s' andmebaasile '%-.192s'"
fre "Accès refusé pour l'utilisateur: '%s'@'%s'. Base '%-.192s'"
ger "Benutzer '%s'@'%s' hat keine Zugriffsberechtigung für Datenbank '%-.192s'"
+ geo "მომხმარებლისთვის '%s'@'%s' ბაზაზე '%-.192s' წვდომა აკრძალულია"
greek "Δεν επιτέρεται η πρόσβαση στο χρήστη: '%s'@'%s' στη βάση δεδομένων '%-.192s'"
hindi "यूज़र '%s'@'%s' को डेटाबेस '%-.192s' की अनुमति नहीं है"
hun "A(z) '%s'@'%s' felhasznalo szamara tiltott eleres az '%-.192s' adabazishoz"
@@ -1096,6 +1139,7 @@ ER_ACCESS_DENIED_ERROR 28000
est "Ligipääs keelatud kasutajale '%s'@'%s' (kasutab parooli: %s)"
fre "Accès refusé pour l'utilisateur: '%s'@'%s' (mot de passe: %s)"
ger "Benutzer '%s'@'%s' hat keine Zugriffsberechtigung (verwendetes Passwort: %s)"
+ geo "მომხმარებლისთვის '%s'@'%s' წვდომა აკრძალულია (პაროლის გამოყენებით: %s)"
greek "Δεν επιτέρεται η πρόσβαση στο χρήστη: '%s'@'%s' (χρήση password: %s)"
hindi "यूज़र '%s'@'%s' को अनुमति नहीं है (पासवर्ड का उपयोग: %s)"
hun "A(z) '%s'@'%s' felhasznalo szamara tiltott eleres. (Hasznalja a jelszot: %s)"
@@ -1121,6 +1165,7 @@ ER_NO_DB_ERROR 3D000
est "Andmebaasi ei ole valitud"
fre "Aucune base n'a été sélectionnée"
ger "Keine Datenbank ausgewählt"
+ geo "მონაცემთა ბაზა არჩეული არაა"
greek "Δεν επιλέχθηκε βάση δεδομένων"
hindi "किसी भी डेटाबेस का चयन नहीं किया गया है"
hun "Nincs kivalasztott adatbazis"
@@ -1147,6 +1192,7 @@ ER_UNKNOWN_COM_ERROR 08S01
est "Tundmatu käsk"
fre "Commande inconnue"
ger "Unbekannter Befehl"
+ geo "უცნობი ბრძანება"
greek "Αγνωστη εντολή"
hindi "अज्ञात आदेश"
hun "Ervenytelen parancs"
@@ -1173,6 +1219,7 @@ ER_BAD_NULL_ERROR 23000
est "Tulp '%-.192s' ei saa omada nullväärtust"
fre "Le champ '%-.192s' ne peut être vide (null)"
ger "Feld '%-.192s' darf nicht NULL sein"
+ geo "სვეტს '%-.192s' მნიშვნელობა NULL ვერ ექნება"
greek "Το πεδίο '%-.192s' δεν μπορεί να είναι κενό (null)"
hindi "काँलम '%-.192s' NULL नहीं हो सकता"
hun "A(z) '%-.192s' oszlop erteke nem lehet nulla"
@@ -1199,6 +1246,7 @@ ER_BAD_DB_ERROR 42000
est "Tundmatu andmebaas '%-.192s'"
fre "Base '%-.192s' inconnue"
ger "Unbekannte Datenbank '%-.192s'"
+ geo "უცნობი მონაცემთა ბაზა '%-.192s'"
greek "Αγνωστη βάση δεδομένων '%-.192s'"
hindi "अज्ञात डाटाबेस '%-.192s'"
hun "Ervenytelen adatbazis: '%-.192s'"
@@ -1225,6 +1273,7 @@ ER_TABLE_EXISTS_ERROR 42S01
est "Tabel '%-.192s' juba eksisteerib"
fre "La table '%-.192s' existe déjà"
ger "Tabelle '%-.192s' bereits vorhanden"
+ geo "ცხრილი '%-.192s' უკვე არსებობს"
greek "Ο πίνακας '%-.192s' υπάρχει ήδη"
hindi "टेबल '%-.192s' पहले से ही मौजूद है"
hun "A(z) '%-.192s' tabla mar letezik"
@@ -1251,6 +1300,7 @@ ER_BAD_TABLE_ERROR 42S02
est "Tundmatu tabel '%-.100T'"
fre "Table '%-.100T' inconnue"
ger "Unbekannte Tabelle '%-.100T'"
+ geo "უცნობი ცხრილი '%-.100T'"
greek "Αγνωστος πίνακας '%-.100T'"
hindi "अज्ञात टेबल '%-.100T'"
hun "Ervenytelen tabla: '%-.100T'"
@@ -1277,6 +1327,7 @@ ER_NON_UNIQ_ERROR 23000
est "Väli '%-.192s' %-.192s-s ei ole ühene"
fre "Champ: '%-.192s' dans %-.192s est ambigu"
ger "Feld '%-.192s' in %-.192s ist nicht eindeutig"
+ geo "სვეტი '%-.192s' %-.192s-ში ბუნდოვანია"
greek "Το πεδίο: '%-.192s' σε %-.192s δεν έχει καθοριστεί"
hindi "काँलम '%-.192s' अस्पष्ट है (टेबल: %-.192s)"
hun "A(z) '%-.192s' oszlop %-.192s-ben ketertelmu"
@@ -1303,6 +1354,7 @@ ER_SERVER_SHUTDOWN 08S01
est "Serveri seiskamine käib"
fre "Arrêt du serveur en cours"
ger "Der Server wird heruntergefahren"
+ geo "მიმდინარეობს სერვერის გამორთვა"
greek "Εναρξη διαδικασίας αποσύνδεσης του εξυπηρετητή (server shutdown)"
hindi "सर्वर बंद हो रहा है"
hun "A szerver leallitasa folyamatban"
@@ -1329,6 +1381,7 @@ ER_BAD_FIELD_ERROR 42S22 S0022
est "Tundmatu tulp '%-.192s' '%-.192s'-s"
fre "Champ '%-.192s' inconnu dans %-.192s"
ger "Unbekanntes Tabellenfeld '%-.192s' in %-.192s"
+ geo "უცნობი სვეტი '%-.192s' '%-.192s'-ში"
greek "Αγνωστο πεδίο '%-.192s' σε '%-.192s'"
hindi "अज्ञात काँलम '%-.192s'(टेबल: '%-.192s')"
hun "A(z) '%-.192s' oszlop ervenytelen '%-.192s'-ben"
@@ -1355,6 +1408,7 @@ ER_WRONG_FIELD_WITH_GROUP 42000 S1009
est "'%-.192s' puudub GROUP BY klauslis"
fre "'%-.192s' n'est pas dans 'group by'"
ger "'%-.192s' ist nicht in GROUP BY vorhanden"
+ geo "'%-.192s' GROUP BY-ში არაა"
greek "Χρησιμοποιήθηκε '%-.192s' που δεν υπήρχε στο group by"
hindi "'%-.192s' GROUP BY में नहीं है"
hun "Used '%-.192s' with wasn't in group by"
@@ -1381,6 +1435,7 @@ ER_WRONG_GROUP_FIELD 42000 S1009
est "Ei saa grupeerida '%-.192s' järgi"
fre "Ne peut regrouper '%-.192s'"
ger "Gruppierung über '%-.192s' nicht möglich"
+ geo "'%-.192s'-ის მიხედვით დაჯგუფების შეცდომა"
greek "Αδύνατη η ομαδοποίηση (group on) '%-.192s'"
hindi "'%-.192s' पर GROUP नहीं कर सकते"
hun "A group nem hasznalhato: '%-.192s'"
@@ -1407,6 +1462,7 @@ ER_WRONG_SUM_SELECT 42000 S1009
est "Lauses on korraga nii tulbad kui summeerimisfunktsioonid"
fre "Vous demandez la fonction sum() et des champs dans la même commande"
ger "Die Verwendung von Summierungsfunktionen und Spalten im selben Befehl ist nicht erlaubt"
+ geo "გამოსახულება შეჯამების ფუნქციებს და სვეტებს ერთდროულად შეიცავს"
greek "Η διατύπωση περιέχει sum functions και columns στην ίδια διατύπωση"
ita "Il comando ha una funzione SUM e una colonna non specificata nella GROUP BY"
jpn "集計関数と通常の列が同時に指定されています。"
@@ -1430,6 +1486,7 @@ ER_WRONG_VALUE_COUNT 21S01
eng "Column count doesn't match value count"
est "Tulpade arv erineb väärtuste arvust"
ger "Die Anzahl der Spalten entspricht nicht der Anzahl der Werte"
+ geo "სვეტების რაოდენობა მნიშვნელობების რაოდენობას არ ემთხვევა"
greek "Το Column count δεν ταιριάζει με το value count"
hindi "कॉलम की गिनती मूल्य की गिनती के समान नही है"
hun "Az oszlopban levo ertek nem egyezik meg a szamitott ertekkel"
@@ -1456,6 +1513,7 @@ ER_TOO_LONG_IDENT 42000 S1009
est "Identifikaatori '%-.100T' nimi on liiga pikk"
fre "Le nom de l'identificateur '%-.100T' est trop long"
ger "Name des Bezeichners '%-.100T' ist zu lang"
+ geo "იდენტიფიკატორის სახელი ('%-.100T') ძალიან გრძელია"
greek "Το identifier name '%-.100T' είναι πολύ μεγάλο"
hindi "पहचानकर्ता का नाम '%-.100T' बहुत लंबा है"
hun "A(z) '%-.100T' azonositonev tul hosszu"
@@ -1482,6 +1540,7 @@ ER_DUP_FIELDNAME 42S21 S1009
est "Kattuv tulba nimi '%-.192s'"
fre "Nom du champ '%-.192s' déjà utilisé"
ger "Doppelter Spaltenname: '%-.192s'"
+ geo "სვეტის დუბლირებული სახელი '%-.192s'"
greek "Επανάληψη column name '%-.192s'"
hindi "समान कॉलम '%-.192s' मौजूद है"
hun "Duplikalt oszlopazonosito: '%-.192s'"
@@ -1508,6 +1567,7 @@ ER_DUP_KEYNAME 42000 S1009
est "Kattuv võtme nimi '%-.192s'"
fre "Nom de clef '%-.192s' déjà utilisé"
ger "Doppelter Name für Schlüssel vorhanden: '%-.192s'"
+ geo "გასაღების დუბლირებული სახელი '%-.192s'"
greek "Επανάληψη key name '%-.192s'"
hindi "समान KEY '%-.192s' मौजूद है"
hun "Duplikalt kulcsazonosito: '%-.192s'"
@@ -1536,6 +1596,7 @@ ER_DUP_ENTRY 23000 S1009
est "Kattuv väärtus '%-.192T' võtmele %d"
fre "Duplicata du champ '%-.192T' pour la clef %d"
ger "Doppelter Eintrag '%-.192T' für Schlüssel %d"
+ geo "დუბლირებული ჩანაწერი '%-.192T' გასაღებისთვის %d"
greek "Διπλή εγγραφή '%-.192T' για το κλειδί %d"
hindi "सामान प्रवेश '%-.192T' KEY %d के लिए"
hun "Duplikalt bejegyzes '%-.192T' a %d kulcs szerint"
@@ -1561,6 +1622,7 @@ ER_WRONG_FIELD_SPEC 42000 S1009
eng "Incorrect column specifier for column '%-.192s'"
est "Vigane tulba kirjeldus tulbale '%-.192s'"
fre "Mauvais paramètre de champ pour le champ '%-.192s'"
+ geo "სვეტის არასწორი მსაზღვრავი სვეტისთვის '%-.192s'"
ger "Falsche Spezifikation für Feld '%-.192s'"
greek "Εσφαλμένο column specifier για το πεδίο '%-.192s'"
hindi "कॉलम '%-.192s' के लिए गलत कॉलम विनिर्देशक"
@@ -1588,6 +1650,7 @@ ER_PARSE_ERROR 42000 s1009
est "%s '%-.80T' ligidal real %d"
fre "%s près de '%-.80T' à la ligne %d"
ger "%s bei '%-.80T' in Zeile %d"
+ geo "%s '%-.80T'-სთან ახლოს ხაზზე %d"
greek "%s πλησίον '%-.80T' στη γραμμή %d"
hindi "%s के पास '%-.80T' लाइन %d में"
hun "A %s a '%-.80T'-hez kozeli a %d sorban"
@@ -1614,6 +1677,7 @@ ER_EMPTY_QUERY 42000
est "Tühi päring"
fre "Query est vide"
ger "Leere Abfrage"
+ geo "მოთხოვნა ცარიელია"
greek "Το ερώτημα (query) που θέσατε ήταν κενό"
hindi "क्वेरी खली थी"
hun "Ures lekerdezes"
@@ -1640,6 +1704,7 @@ ER_NONUNIQ_TABLE 42000 S1009
est "Ei ole unikaalne tabel/alias '%-.192s'"
fre "Table/alias: '%-.192s' non unique"
ger "Tabellenname/Alias '%-.192s' nicht eindeutig"
+ geo "ცხრილი/ფსევდონიმი უნიკალური არაა: '%-.192s'"
greek "Αδύνατη η ανεύρεση unique table/alias: '%-.192s'"
hindi "टेबल या उसका उपनाम '%-.192s' अद्वितीय नहीं है"
hun "Nem egyedi tabla/alias: '%-.192s'"
@@ -1666,6 +1731,7 @@ ER_INVALID_DEFAULT 42000 S1009
est "Vigane vaikeväärtus '%-.192s' jaoks"
fre "Valeur par défaut invalide pour '%-.192s'"
ger "Fehlerhafter Vorgabewert (DEFAULT) für '%-.192s'"
+ geo "არასწორი ნაგულისხმები მნიშვნელობა '%-.192s'-სთვის"
greek "Εσφαλμένη προκαθορισμένη τιμή (default value) για '%-.192s'"
hindi "'%-.192s' के लिए अवैध डिफ़ॉल्ट मान"
hun "Ervenytelen ertek: '%-.192s'"
@@ -1692,6 +1758,7 @@ ER_MULTIPLE_PRI_KEY 42000 S1009
est "Mitut primaarset võtit ei saa olla"
fre "Plusieurs clefs primaires définies"
ger "Mehrere Primärschlüssel (PRIMARY KEY) definiert"
+ geo "აღწერილია ერთზე მეტი ძირითადი გასაღები (PRIMARY KEY)"
greek "Περισσότερα από ένα primary key ορίστηκαν"
hindi "कई PRIMARY KEY परिभाषित"
hun "Tobbszoros elsodleges kulcs definialas"
@@ -1718,6 +1785,7 @@ ER_TOO_MANY_KEYS 42000 S1009
est "Liiga palju võtmeid. Maksimaalselt võib olla %d võtit"
fre "Trop de clefs sont définies. Maximum de %d clefs alloué"
ger "Zu viele Schlüssel definiert. Maximal %d Schlüssel erlaubt"
+ geo "მითითებულია მეტისმეტად ბევრი გასაღები. დაშვებულია მაქსიმუმ %d"
greek "Πάρα πολλά key ορίσθηκαν. Το πολύ %d επιτρέπονται"
hindi "बहुत सारी KEYS निर्दिष्ट हैं; अधिकतम %d KEYS की अनुमति है"
hun "Tul sok kulcs. Maximum %d kulcs engedelyezett"
@@ -1744,6 +1812,7 @@ ER_TOO_MANY_KEY_PARTS 42000 S1009
est "Võti koosneb liiga paljudest osadest. Maksimaalselt võib olla %d osa"
fre "Trop de parties specifiées dans la clef. Maximum de %d parties"
ger "Zu viele Teilschlüssel definiert. Maximal %d Teilschlüssel erlaubt"
+ geo "მითითებულია მეტისმეტად ბევრი ნაწილი. დაშვებულია მაქსიმუმ %d"
greek "Πάρα πολλά key parts ορίσθηκαν. Το πολύ %d επιτρέπονται"
hindi "बहुत सारे KEY के भाग निर्दिष्ट हैं; अधिकतम %d भागों की अनुमति है"
hun "Tul sok kulcsdarabot definialt. Maximum %d resz engedelyezett"
@@ -1770,6 +1839,7 @@ ER_TOO_LONG_KEY 42000 S1009
est "Võti on liiga pikk. Maksimaalne võtmepikkus on %d"
fre "La clé est trop longue. Longueur maximale: %d"
ger "Schlüssel ist zu lang. Die maximale Schlüssellänge beträgt %d"
+ geo "მითითებული გასაღები მეტისმეტად გრძელია. დასაშვები მაქსიმალური სიგრძე: %d"
greek "Το κλειδί που ορίσθηκε είναι πολύ μεγάλο. Το μέγιστο μήκος είναι %d"
hindi "निर्दिष्ट KEY बहुत लंबी थी; KEY की अधिकतम लंबाई %d बाइट है"
hun "A megadott kulcs tul hosszu. Maximalis kulcshosszusag: %d"
@@ -1796,6 +1866,7 @@ ER_KEY_COLUMN_DOES_NOT_EXIST 42000 S1009
est "Võtme tulp '%-.192s' puudub tabelis"
fre "La clé '%-.192s' n'existe pas dans la table"
ger "In der Tabelle gibt es kein Schlüsselfeld '%-.192s'"
+ geo "გასაღების სვეტი '%-.192s' ცხრილში არ არსებობს"
greek "Το πεδίο κλειδί '%-.192s' δεν υπάρχει στον πίνακα"
hindi "KEY कॉलम '%-.192s' टेबल में मौजूद नहीं है"
hun "A(z) '%-.192s'kulcsoszlop nem letezik a tablaban"
@@ -1818,6 +1889,7 @@ ER_BLOB_USED_AS_KEY 42000 S1009
chi "索引里不能含有BLOB列%`s表%s"
eng "BLOB column %`s can't be used in key specification in the %s table"
ger "BLOB-Feld %`s kann beim %s Tabellen nicht als Schlüssel verwendet werden"
+ geo "BLOB-ის ტიპის სვეტი %`s %s ცხრილში გასაღების მნიშვნელობა ვერ იქნება"
hindi "BLOB कॉलम %`s टेबल %s में KEY विनिर्देश में इस्तेमाल नहीं किया जा सकता"
rus "Столбец типа BLOB %`s не может быть использован как значение ключа в %s таблице"
spa "La columna BLOB %`s no se puede usar en la especificación de clave en la tabla %s"
@@ -1830,6 +1902,7 @@ ER_TOO_BIG_FIELDLENGTH 42000 S1009
est "Tulba '%-.192s' pikkus on liiga pikk (maksimaalne pikkus: %lu). Kasuta BLOB väljatüüpi"
fre "Champ '%-.192s' trop long (max = %lu). Utilisez un BLOB"
ger "Feldlänge für Feld '%-.192s' zu groß (maximal %lu). BLOB- oder TEXT-Spaltentyp verwenden!"
+ geo "სვეტის სიგრძე სვეტისთვის '%-.192s' მეტისმეტად დიდია (მაქს = %lu). სცადეთ, ამის მაგიერ BLOB ან TEXT გამოიყენოთ"
greek "Πολύ μεγάλο μήκος για το πεδίο '%-.192s' (max = %lu). Παρακαλώ χρησιμοποιείστε τον τύπο BLOB"
hindi "कॉलम की लंबाई कॉलम '%-.192s' के लिए बड़ी है (अधिकतम = %lu); BLOB या TEXT का उपयोग करें"
hun "A(z) '%-.192s' oszlop tul hosszu. (maximum = %lu). Hasznaljon BLOB tipust inkabb"
@@ -1856,6 +1929,7 @@ ER_WRONG_AUTO_KEY 42000 S1009
est "Vigane tabelikirjeldus; Tabelis tohib olla üks auto_increment tüüpi tulp ning see peab olema defineeritud võtmena"
fre "Un seul champ automatique est permis et il doit être indexé"
ger "Falsche Tabellendefinition. Es darf nur eine AUTO_INCREMENT-Spalte geben, und diese muss als Schlüssel definiert werden"
+ geo "ცხრილის არასწორი აღწერა. შეიძლება არსებობდეს მხოლოდ ერთი თვითზრდადი სვეტი და ის როგორც გასაღები, ისე უნდა აღწეროთ"
greek "Μπορεί να υπάρχει μόνο ένα auto field και πρέπει να έχει ορισθεί σαν key"
hindi "गलत टेबल परिभाषा; टेबल में केवल एक AUTO_INCREMENT कॉलम हो सकता है और इसे एक KEY के रूप में परिभाषित किया जाना चाहिए"
hun "Csak egy auto mezo lehetseges, es azt kulcskent kell definialni"
@@ -1877,6 +1951,7 @@ ER_WRONG_AUTO_KEY 42000 S1009
ER_BINLOG_CANT_DELETE_GTID_DOMAIN
chi "无法删除gtid域. 原因: %s."
eng "Could not delete gtid domain. Reason: %s."
+ geo "შეცდომა gtid დომენის წაშლისას. მიზეზი: %s."
spa "No pude borrar el dominio gtid. Motivo: %s."
ukr "Не можу видалити домен gtid. Причина: %s."
ER_NORMAL_SHUTDOWN
@@ -1887,6 +1962,7 @@ ER_NORMAL_SHUTDOWN
est "%s (%s): MariaDB lõpetas"
fre "%s (%s): Arrêt normal du serveur"
ger "%s (%s): Normal heruntergefahren"
+ geo "%s (%s): მუშაობის ნორმალური დასრულება"
greek "%s (%s): Φυσιολογική διαδικασία shutdown"
hindi "%s (%s): सामान्य शटडाउन"
hun "%s (%s): Normal leallitas"
@@ -1913,6 +1989,7 @@ ER_GOT_SIGNAL
est "%s: sain signaali %d. Lõpetan!\n"
fre "%s: Reçu le signal %d. Abandonne!\n"
ger "%s: Signal %d erhalten. Abbruch!\n"
+ geo "%s: მიღებულია სიგნალი %d. გაუქმება! \n"
greek "%s: Ελήφθη το μήνυμα %d. Η διαδικασία εγκαταλείπεται!\n"
hindi "%s: सिग्नल %d मिलने के कारण सिस्टम बंद किया जा रहा है!\n"
hun "%s: %d jelzes. Megszakitva!\n"
@@ -1939,6 +2016,7 @@ ER_SHUTDOWN_COMPLETE
est "%s: Lõpp\n"
fre "%s: Arrêt du serveur terminé\n"
ger "%s: Herunterfahren beendet\n"
+ geo "%s: მუშაობა წარმატებიტ დასრულდა\n"
greek "%s: Η διαδικασία Shutdown ολοκληρώθηκε\n"
hindi "%s: शटडाउन पूर्ण\n"
hun "%s: A leallitas kesz\n"
@@ -1965,6 +2043,7 @@ ER_FORCING_CLOSE 08S01
est "%s: Sulgen jõuga lõime %ld kasutaja: '%-.48s'\n"
fre "%s: Arrêt forcé de la tâche (thread) %ld utilisateur: '%-.48s'\n"
ger "%s: Thread %ld zwangsweise beendet. Benutzer: '%-.48s'\n"
+ geo "%s: ნაძალადევი დახურვა: ნაკადი: %ld, მომხმარებელი: '%-.48s'\n"
greek "%s: Το thread θα κλείσει %ld user: '%-.48s'\n"
hindi "%s: %ld थ्रेड बंद किया जा रहा है (यूज़र: '%-.48s')\n"
hun "%s: A(z) %ld thread kenyszeritett zarasa. Felhasznalo: '%-.48s'\n"
@@ -1991,6 +2070,7 @@ ER_IPSOCK_ERROR 08S01
est "Ei suuda luua IP socketit"
fre "Ne peut créer la connexion IP (socket)"
ger "Kann IP-Socket nicht erzeugen"
+ geo "IP სოკეტის შექმნა შეუძლებელია"
greek "Δεν είναι δυνατή η δημιουργία IP socket"
hindi "IP SOCKET नहीं बना सकते"
hun "Az IP socket nem hozhato letre"
@@ -2017,6 +2097,7 @@ ER_NO_SUCH_INDEX 42S12 S1009
est "Tabelil '%-.192s' puuduvad võtmed. Loo tabel uuesti"
fre "La table '%-.192s' n'a pas d'index comme celle utilisée dans CREATE INDEX. Recréez la table"
ger "Tabelle '%-.192s' besitzt keinen wie den in CREATE INDEX verwendeten Index. Tabelle neu anlegen"
+ geo "ცხრილს '%-.192s' ინდექსი, როგორიც CREATE INDEX-ში იყო გამოყენებული, არ გააჩნია. ცხრილი თავიდან შექმენით"
greek "Ο πίνακας '%-.192s' δεν έχει ευρετήριο (index) σαν αυτό που χρησιμοποιείτε στην CREATE INDEX. Παρακαλώ, ξαναδημιουργήστε τον πίνακα"
hindi "CREATE INDEX में इस्तेमाल की गयी सूचि टेबल '%-.192s' में उपलब्ध नहीं है; टेबल को पुनः बनायें"
hun "A(z) '%-.192s' tablahoz nincs meg a CREATE INDEX altal hasznalt index. Alakitsa at a tablat"
@@ -2043,6 +2124,7 @@ ER_WRONG_FIELD_TERMINATORS 42000 S1009
est "Väljade eraldaja erineb oodatust. Tutvu kasutajajuhendiga"
fre "Séparateur de champs inconnu. Vérifiez dans le manuel"
ger "Feldbegrenzer-Argument ist nicht in der erwarteten Form. Bitte im Handbuch nachlesen"
+ geo "ველის გამყოფის არგუმენტი მოსალოდნელს არ ემთხვევა. გადაამოწმეთ დოკუმენტაციაში"
greek "Ο διαχωριστής πεδίων δεν είναι αυτός που αναμενόταν. Παρακαλώ ανατρέξτε στο manual"
hindi "फील्ड विभाजक आर्गुमेंट गलत है; मैनुअल की जाँच करें"
hun "A mezoelvalaszto argumentumok nem egyeznek meg a varttal. Nezze meg a kezikonyvben!"
@@ -2069,6 +2151,7 @@ ER_BLOBS_AND_NO_TERMINATED 42000 S1009
est "BLOB-tüüpi väljade olemasolul ei saa kasutada fikseeritud väljapikkust. Vajalik 'fields terminated by' määrang"
fre "Vous ne pouvez utiliser des lignes de longueur fixe avec des BLOBs. Utiliser 'fields terminated by'"
ger "Eine feste Zeilenlänge kann für BLOB-Felder nicht verwendet werden. Bitte 'fields terminated by' verwenden"
+ geo "ფიქსირებულზომიანი მწკრივის სიგრძეს BLOB-თან ერთად ვერ გამოიყენებთ. გამოიყენეთ 'fieds terminated by'"
greek "Δεν μπορείτε να χρησιμοποιήσετε fixed rowlength σε BLOBs. Παρακαλώ χρησιμοποιείστε 'fields terminated by'"
hindi "BLOBs को निश्चित लंबाई की पंक्ति के साथ प्रयोग नहीं किया जा सकता है; 'FIELDS TERMINATED BY' का इस्तेमाल करें"
hun "Fix hosszusagu BLOB-ok nem hasznalhatok. Hasznalja a 'mezoelvalaszto jelet' "
@@ -2095,6 +2178,7 @@ ER_TEXTFILE_NOT_READABLE
est "Fail '%-.128s' peab asuma andmebaasi kataloogis või olema kõigile loetav"
fre "Le fichier '%-.128s' doit être dans le répertoire de la base et lisible par tous"
ger "Datei '%-.128s' muss im Datenbank-Verzeichnis vorhanden oder lesbar für alle sein"
+ geo "ფაილი '%-.128s' მონაცემთა ბაზის საქაღალდეში უნდა მდებარეობდეს, ან ყველას მიერ უნდა იყოს წაკითხვადი"
greek "Το αρχείο '%-.128s' πρέπει να υπάρχει στο database directory ή να μπορεί να διαβαστεί από όλους"
hindi "फ़ाइल '%-.128s' डेटाबेस डायरेक्टरी में या सभी के द्वारा पठनीय होना चाहिए"
hun "A(z) '%-.128s'-nak az adatbazis konyvtarban kell lennie, vagy mindenki szamara olvashatonak"
@@ -2121,6 +2205,7 @@ ER_FILE_EXISTS_ERROR
est "Fail '%-.200s' juba eksisteerib"
fre "Le fichier '%-.200s' existe déjà"
ger "Datei '%-.200s' bereits vorhanden"
+ geo "ფაილი '%-.200s' უკვე არსებობს"
greek "Το αρχείο '%-.200s' υπάρχει ήδη"
hindi "फ़ाइल '%-.200s' पहले से मौजूद है"
hun "A '%-.200s' file mar letezik"
@@ -2147,6 +2232,7 @@ ER_LOAD_INFO
est "Kirjeid: %ld Kustutatud: %ld Vahele jäetud: %ld Hoiatusi: %ld"
fre "Enregistrements: %ld Effacés: %ld Non traités: %ld Avertissements: %ld"
ger "Datensätze: %ld Gelöscht: %ld Ausgelassen: %ld Warnungen: %ld"
+ geo "ჩანაწერები: %ld წაშლილია: %ld გამოტოვებულია: %ld გაფრთხილებები: %ld"
greek "Εγγραφές: %ld Διαγραφές: %ld Παρεκάμφθησαν: %ld Προειδοποιήσεις: %ld"
hindi "रिकॉर्ड: %ld हटाए गए: %ld छोड़ दिए गए: %ld चेतावनी: %ld"
hun "Rekordok: %ld Torolve: %ld Skipped: %ld Warnings: %ld"
@@ -2173,6 +2259,7 @@ ER_ALTER_INFO
est "Kirjeid: %ld Kattuvaid: %ld"
fre "Enregistrements: %ld Doublons: %ld"
ger "Datensätze: %ld Duplikate: %ld"
+ geo "ჩანაწერები: %ld დუბლიკატები: %ld"
greek "Εγγραφές: %ld Επαναλήψεις: %ld"
hindi "रिकॉर्ड: %ld डुप्लिकेट: %ld"
hun "Rekordok: %ld Duplikalva: %ld"
@@ -2199,6 +2286,7 @@ ER_WRONG_SUB_KEY
est "Vigane võtme osa. Kasutatud võtmeosa ei ole string tüüpi, määratud pikkus on pikem kui võtmeosa või tabelihandler ei toeta seda tüüpi võtmeid"
fre "Mauvaise sous-clef. Ce n'est pas un 'string' ou la longueur dépasse celle définie dans la clef"
ger "Falscher Unterteilschlüssel. Der verwendete Schlüsselteil ist entweder kein String, die verwendete Länge ist länger als der Teilschlüssel oder die Speicher-Engine unterstützt keine Unterteilschlüssel"
+ geo "პრეფიქსის არასწორი გასაღები. გასაღების გამოყენებადი ნაწილი სტრიქონს არ წარმოადგენს. მითითებული სიგრძე უფრო დიდია, ვიდრე გასაღების ნაწილის სიგრძე, ან საცავის ძრავას უნიკალური პრეფიქსის გასაღებების მხარდაჭერა არ გააჩნია"
greek "Εσφαλμένο sub part key. Το χρησιμοποιούμενο key part δεν είναι string ή το μήκος του είναι μεγαλύτερο"
hun "Rossz alkulcs. A hasznalt kulcsresz nem karaktersorozat vagy hosszabb, mint a kulcsresz"
ita "Sotto-parte della chiave errata. La parte di chiave utilizzata non e` una stringa o la lunghezza e` maggiore della parte di chiave"
@@ -2224,6 +2312,7 @@ ER_CANT_REMOVE_ALL_FIELDS 42000
est "ALTER TABLE kasutades ei saa kustutada kõiki tulpasid. Kustuta tabel DROP TABLE abil"
fre "Vous ne pouvez effacer tous les champs avec ALTER TABLE. Utilisez DROP TABLE"
ger "Mit ALTER TABLE können nicht alle Felder auf einmal gelöscht werden. Dafür DROP TABLE verwenden"
+ geo "ALTER TABLE-ით ყველა სვეტს ვერ წაშლით. გამოიყენეთ DROP TABLE"
greek "Δεν είναι δυνατή η διαγραφή όλων των πεδίων με ALTER TABLE. Παρακαλώ χρησιμοποιείστε DROP TABLE"
hindi "ALTER TABLE का इस्तेमाल कर सभी कॉलम्स को हटाया नहीं जा सकता; DROP TABLE का इस्तेमाल करें"
hun "Az osszes mezo nem torolheto az ALTER TABLE-lel. Hasznalja a DROP TABLE-t helyette"
@@ -2250,6 +2339,7 @@ ER_CANT_DROP_FIELD_OR_KEY 42000
est "Ei suuda kustutada (DROP %s) %`-.192s. Kontrolli kas tulp/võti eksisteerib"
fre "Ne peut effacer (DROP %s) %`-.192s. Vérifiez s'il existe"
ger "DROP %s: Kann %`-.192s nicht löschen. Existiert es?"
+ geo "DROP %s %`-.192s შეუძლებელია. შეამოწმეთ, არსებობს თუ არა ის"
greek "Αδύνατη η διαγραφή (DROP %s) %`-.192s. Παρακαλώ ελέγξτε αν το πεδίο/κλειδί υπάρχει"
hindi "%s %`-.192s को ड्रॉप नहीं कर सकते हैं; कृपया जाँच करें कि यह मौजूद है"
hun "A DROP %s %`-.192s nem lehetseges. Ellenorizze, hogy a mezo/kulcs letezik-e"
@@ -2274,6 +2364,7 @@ ER_INSERT_INFO
est "Kirjeid: %ld Kattuvaid: %ld Hoiatusi: %ld"
fre "Enregistrements: %ld Doublons: %ld Avertissements: %ld"
ger "Datensätze: %ld Duplikate: %ld Warnungen: %ld"
+ geo "ჩანაწერები: %ld დუბლიკატები: %ld გაფრთხილებები: %ld"
greek "Εγγραφές: %ld Επαναλήψεις: %ld Προειδοποιήσεις: %ld"
hindi "रिकॉर्ड: %ld डुप्लिकेट: %ld चेतावनी: %ld"
hun "Rekordok: %ld Duplikalva: %ld Warnings: %ld"
@@ -2295,6 +2386,7 @@ ER_INSERT_INFO
ER_UPDATE_TABLE_USED
chi "表 '%-.192s' 被指定了两次, 即作为 '%s' 的目标,又作为数据的独立源"
eng "Table '%-.192s' is specified twice, both as a target for '%s' and as a separate source for data"
+ geo "ცხრილი '%-.192s' ორჯერაა მითითებული, ორივეჯერ როგორც '%s'-ის სამიზნე და როგორც მონაცემების ცალკე წყარო"
swe "Table '%-.192s' är använd två gånger. Både för '%s' och för att hämta data"
ukr "Таблиця '%-.192s' вказується двічі, як цільова для '%s', так і як окреме джерело даних"
ER_NO_SUCH_THREAD
@@ -2305,6 +2397,7 @@ ER_NO_SUCH_THREAD
est "Tundmatu lõim: %lu"
fre "Numéro de tâche inconnu: %lu"
ger "Unbekannte Thread-ID: %lu"
+ geo "უცნობი ნაკადის ID: %lu"
greek "Αγνωστο thread id: %lu"
hindi "अज्ञात थ्रेड ID: %lu"
hun "Ervenytelen szal (thread) id: %lu"
@@ -2331,6 +2424,7 @@ ER_KILL_DENIED_ERROR
est "Ei ole lõime %lld omanik"
fre "Vous n'êtes pas propriétaire de la tâche no: %lld"
ger "Sie sind nicht Eigentümer von Thread %lld"
+ geo "თქვენ ნაკადის %lld მფლობელი არ ბრძანდებით"
greek "Δεν είσθε owner του thread %lld"
hindi "आप थ्रेड %lld के OWNER नहीं हैं"
hun "A %lld thread-nek mas a tulajdonosa"
@@ -2357,6 +2451,7 @@ ER_NO_TABLES_USED
est "Ühtegi tabelit pole kasutusel"
fre "Aucune table utilisée"
ger "Keine Tabellen verwendet"
+ geo "ცხრილები გამოყენებული არაა"
greek "Δεν χρησιμοποιήθηκαν πίνακες"
hindi "कोई टेबल का इस्तेमाल नहीं हुआ"
hun "Nincs hasznalt tabla"
@@ -2383,6 +2478,7 @@ ER_TOO_BIG_SET
est "Liiga palju string tulbale %-.192s tüübile SET"
fre "Trop de chaînes dans la colonne %-.192s avec SET"
ger "Zu viele Strings für Feld %-.192s und SET angegeben"
+ geo "მეტისმეტად ბევრი სტრიქონი სვეტისთვის %-.192s და SET"
greek "Πάρα πολλά strings για το πεδίο %-.192s και SET"
hun "Tul sok karakter: %-.192s es SET"
ita "Troppe stringhe per la colonna %-.192s e la SET"
@@ -2408,6 +2504,7 @@ ER_NO_UNIQUE_LOGFILE
est "Ei suuda luua unikaalset logifaili nime %-.200s.(1-999)\n"
fre "Ne peut générer un unique nom de journal %-.200s.(1-999)\n"
ger "Kann keinen eindeutigen Dateinamen für die Logdatei %-.200s(1-999) erzeugen\n"
+ geo "უნიკალური ჟურნალის ფაილის სახელის %-.200s.(1-999) შექმნის შეცდომა\n"
greek "Αδύνατη η δημιουργία unique log-filename %-.200s.(1-999)\n"
hindi "एक अनूठा लॉग-फ़ाइल नाम %-.200s.(1-999) उत्पन्न नहीं कर सके\n"
hun "Egyedi log-filenev nem generalhato: %-.200s.(1-999)\n"
@@ -2434,6 +2531,7 @@ ER_TABLE_NOT_LOCKED_FOR_WRITE
est "Tabel '%-.192s' on lukustatud READ lukuga ning ei ole muudetav"
fre "Table '%-.192s' verrouillée lecture (READ): modification impossible"
ger "Tabelle '%-.192s' ist mit Lesesperre versehen und kann nicht aktualisiert werden"
+ geo "ცხრილი '%-.192s' დაბლოკილია READ ბლოკით და მისი განახლება შეუძლებელია"
greek "Ο πίνακας '%-.192s' έχει κλειδωθεί με READ lock και δεν επιτρέπονται αλλαγές"
hindi "टेबल '%-.192s' READ लॉक से बंद है और उसे बदल नहीं सकते"
hun "A(z) '%-.192s' tabla zarolva lett (READ lock) es nem lehet frissiteni"
@@ -2460,6 +2558,7 @@ ER_TABLE_NOT_LOCKED
est "Tabel '%-.192s' ei ole lukustatud käsuga LOCK TABLES"
fre "Table '%-.192s' non verrouillée: utilisez LOCK TABLES"
ger "Tabelle '%-.192s' wurde nicht mit LOCK TABLES gesperrt"
+ geo "ცხრილი '%-.192s' LOCK TABLES-ით დაბლოკილი არაა"
greek "Ο πίνακας '%-.192s' δεν έχει κλειδωθεί με LOCK TABLES"
hindi "टेबल '%-.192s' LOCK TABLES से बंद नहीं है"
hun "A(z) '%-.192s' tabla nincs zarolva a LOCK TABLES-szel"
@@ -2481,6 +2580,7 @@ ER_TABLE_NOT_LOCKED
ER_UNUSED_17
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ის ვერასდროს უნდა დაგენახათ"
spa "Nunca debería vd de ver esto"
ER_WRONG_DB_NAME 42000
chi "数据库名称不正确'%-.100T'"
@@ -2490,6 +2590,7 @@ ER_WRONG_DB_NAME 42000
est "Vigane andmebaasi nimi '%-.100T'"
fre "Nom de base de donnée illégal: '%-.100T'"
ger "Unerlaubter Datenbankname '%-.100T'"
+ geo "მონაცემთა ბაზის არასწორი სახელი '%-.100T'"
greek "Λάθος όνομα βάσης δεδομένων '%-.100T'"
hindi "डेटाबेस नाम '%-.100T' गलत है"
hun "Hibas adatbazisnev: '%-.100T'"
@@ -2516,6 +2617,7 @@ ER_WRONG_TABLE_NAME 42000
est "Vigane tabeli nimi '%-.100s'"
fre "Nom de table illégal: '%-.100s'"
ger "Unerlaubter Tabellenname '%-.100s'"
+ geo "არასწორი ცხრილის სახელი '%-.100s'"
greek "Λάθος όνομα πίνακα '%-.100s'"
hindi "टेबल नाम '%-.100s' गलत है"
hun "Hibas tablanev: '%-.100s'"
@@ -2542,6 +2644,7 @@ ER_TOO_BIG_SELECT 42000
est "SELECT lause peab läbi vaatama suure hulga kirjeid ja võtaks tõenäoliselt liiga kaua aega. Tasub kontrollida WHERE klauslit ja vajadusel kasutada käsku SET SQL_BIG_SELECTS=1"
fre "SELECT va devoir examiner beaucoup d'enregistrements ce qui va prendre du temps. Vérifiez la clause WHERE et utilisez SET SQL_BIG_SELECTS=1 si SELECT se passe bien"
ger "Die Ausführung des SELECT würde zu viele Datensätze untersuchen und wahrscheinlich sehr lange dauern. Bitte WHERE-Klausel überprüfen und gegebenenfalls SET SQL_BIG_SELECTS=1 oder SET MAX_JOIN_SIZE=# verwenden"
+ geo "SELECT-ი MAX_JOIN_SIZE-ის მნიშვნელობაზე მეტ ჩანაწერს დაამუშავებდა. შეამოწმეთ თქვენი WHERE და გამოიყენეთ SET SQL_BIG_SELECTS=1 ან SET MAX_JOIN_SIZE=#, თუ SELECT-ი კარგადაა დაწერილი"
greek "Το SELECT θα εξετάσει μεγάλο αριθμό εγγραφών και πιθανώς θα καθυστερήσει. Παρακαλώ εξετάστε τις παραμέτρους του WHERE και χρησιμοποιείστε SET SQL_BIG_SELECTS=1 αν το SELECT είναι σωστό"
hindi "SELECT कमांड MAX_JOIN_SIZE पंक्तियों से भी ज्यादा की जांच करेगा; कृपया WHERE क्लॉज़ को जाचें अथवा SET SQL_BIG_SELECTS=1 या SET MAX_JOIN_SIZE=# का इस्तेमाल करें"
hun "A SELECT tul sok rekordot fog megvizsgalni es nagyon sokaig fog tartani. Ellenorizze a WHERE-t es hasznalja a SET SQL_BIG_SELECTS=1 beallitast, ha a SELECT okay"
@@ -2568,6 +2671,7 @@ ER_UNKNOWN_ERROR
est "Tundmatu viga"
fre "Erreur inconnue"
ger "Unbekannter Fehler"
+ geo "უცნობი შეცდომა"
greek "Προέκυψε άγνωστο λάθος"
hindi "अज्ञात त्रुटि हुई"
hun "Ismeretlen hiba"
@@ -2593,6 +2697,7 @@ ER_UNKNOWN_PROCEDURE 42000
est "Tundmatu protseduur '%-.192s'"
fre "Procédure %-.192s inconnue"
ger "Unbekannte Prozedur '%-.192s'"
+ geo "უცნობი პროცედურა '%-.192s'"
greek "Αγνωστη διαδικασία '%-.192s'"
hindi "अज्ञात प्रोसीजर '%-.192s'"
hun "Ismeretlen eljaras: '%-.192s'"
@@ -2619,6 +2724,7 @@ ER_WRONG_PARAMCOUNT_TO_PROCEDURE 42000
est "Vale parameetrite hulk protseduurile '%-.192s'"
fre "Mauvais nombre de paramètres pour la procedure %-.192s"
ger "Falsche Parameterzahl für Prozedur '%-.192s'"
+ geo "არასწორი პარამეტრების რაოდენობა პროცედურისთვის '%-.192s'"
greek "Λάθος αριθμός παραμέτρων στη διαδικασία '%-.192s'"
hindi "प्रोसीजर '%-.192s' के लिए पैरामीटर की संख्या गलत है"
hun "Rossz parameter a(z) '%-.192s'eljaras szamitasanal"
@@ -2645,6 +2751,7 @@ ER_WRONG_PARAMETERS_TO_PROCEDURE
est "Vigased parameetrid protseduurile '%-.192s'"
fre "Paramètre erroné pour la procedure %-.192s"
ger "Falsche Parameter für Prozedur '%-.192s'"
+ geo "არასწორი პარამეტრები პროცედურისთვის '%-.192s'"
greek "Λάθος παράμετροι στην διαδικασία '%-.192s'"
hindi "प्रोसीजर '%-.192s' के लिए पैरामीटर्स गलत हैं"
hun "Rossz parameter a(z) '%-.192s' eljarasban"
@@ -2671,6 +2778,7 @@ ER_UNKNOWN_TABLE 42S02
est "Tundmatu tabel '%-.192s' %-.32s-s"
fre "Table inconnue '%-.192s' dans %-.32s"
ger "Unbekannte Tabelle '%-.192s' in '%-.32s'"
+ geo "უცნობი ცხრილი '%-.192s' %-.32s-ში"
greek "Αγνωστος πίνακας '%-.192s' σε %-.32s"
hindi "टेबल '%-.192s', %-.32s में नहीं मिला"
hun "Ismeretlen tabla: '%-.192s' %-.32s-ban"
@@ -2697,6 +2805,7 @@ ER_FIELD_SPECIFIED_TWICE 42000
est "Tulp '%-.192s' on määratletud topelt"
fre "Champ '%-.192s' spécifié deux fois"
ger "Feld '%-.192s' wurde zweimal angegeben"
+ geo "სვეტი '%-.192s' ორჯერაა მითითებული"
greek "Το πεδίο '%-.192s' έχει ορισθεί δύο φορές"
hindi "कॉलम '%-.192s' दो बार निर्दिष्ट किया गया है"
hun "A(z) '%-.192s' mezot ketszer definialta"
@@ -2723,6 +2832,7 @@ ER_INVALID_GROUP_FUNC_USE
est "Vigane grupeerimisfunktsiooni kasutus"
fre "Utilisation invalide de la clause GROUP"
ger "Falsche Verwendung einer Gruppierungsfunktion"
+ geo "GROUP ფუნქციის არასწორი გამოყენება"
greek "Εσφαλμένη χρήση της group function"
hindi "ग्रुप फंक्शन का अवैध उपयोग"
hun "A group funkcio ervenytelen hasznalata"
@@ -2746,6 +2856,7 @@ ER_UNSUPPORTED_EXTENSION 42000
est "Tabel '%-.192s' kasutab laiendust, mis ei eksisteeri antud MariaDB versioonis"
fre "Table '%-.192s' : utilise une extension invalide pour cette version de MariaDB"
ger "Tabelle '%-.192s' verwendet eine Erweiterung, die in dieser MariaDB-Version nicht verfügbar ist"
+ geo "ცხრილი '%-.192s' იყენებს გაფართოებას, რომელიც MariaDB-ის ამ ვერსიაში არ არსებობს"
greek "Ο πίνακς '%-.192s' χρησιμοποιεί κάποιο extension που δεν υπάρχει στην έκδοση αυτή της MariaDB"
hindi "टेबल '%-.192s' जिस इक्स्टेन्शन का उपयोग कर रहा है, वह इस MariaDB संस्करण में उपलब्ध नहीं है"
hun "A(z) '%-.192s' tabla olyan bovitest hasznal, amely nem letezik ebben a MariaDB versioban"
@@ -2772,6 +2883,7 @@ ER_TABLE_MUST_HAVE_COLUMNS 42000
est "Tabelis peab olema vähemalt üks tulp"
fre "Une table doit comporter au moins une colonne"
ger "Eine Tabelle muss mindestens eine Spalte besitzen"
+ geo "ცხრილს აუცილებლად უნდა ჰქონდეს 1 სვეტი მაინც"
greek "Ενας πίνακας πρέπει να έχει τουλάχιστον ένα πεδίο"
hindi "एक टेबल में कम से कम एक कॉलम होना चाहिए"
hun "A tablanak legalabb egy oszlopot tartalmazni kell"
@@ -2795,6 +2907,7 @@ ER_RECORD_FILE_FULL
est "Tabel '%-.192s' on täis"
fre "La table '%-.192s' est pleine"
ger "Tabelle '%-.192s' ist voll"
+ geo "ცხრილი '%-.192s' სავსეა"
greek "Ο πίνακας '%-.192s' είναι γεμάτος"
hindi "टेबल '%-.192s' पूरा भरा है"
hun "A '%-.192s' tabla megtelt"
@@ -2818,6 +2931,7 @@ ER_UNKNOWN_CHARACTER_SET 42000
est "Vigane kooditabel '%-.64s'"
fre "Jeu de caractères inconnu: '%-.64s'"
ger "Unbekannter Zeichensatz: '%-.64s'"
+ geo "უცნობი სიმბოლოების სეტი: '%-.64s'"
greek "Αγνωστο character set: '%-.64s'"
hindi "अज्ञात CHARACTER SET: '%-.64s'"
hun "Ervenytelen karakterkeszlet: '%-.64s'"
@@ -2841,6 +2955,7 @@ ER_TOO_MANY_TABLES
est "Liiga palju tabeleid. MariaDB suudab JOINiga ühendada kuni %d tabelit"
fre "Trop de tables. MariaDB ne peut utiliser que %d tables dans un JOIN"
ger "Zu viele Tabellen. MariaDB kann in einem Join maximal %d Tabellen verwenden"
+ geo "მეტისმეტად ბევრი ცხრილი. MariaDB-ს JOIN-ში მხოლოდ %d ცხრილის გამოყენება შეუძლია"
greek "Πολύ μεγάλος αριθμός πινάκων. Η MariaDB μπορεί να χρησιμοποιήσει %d πίνακες σε διαδικασία join"
hindi "बहुत अधिक टेबल्स, MariaDB एक JOIN में केवल %d टेबल्स का उपयोग कर सकता है"
hun "Tul sok tabla. A MariaDB csak %d tablat tud kezelni osszefuzeskor"
@@ -2864,6 +2979,7 @@ ER_TOO_MANY_FIELDS
est "Liiga palju tulpasid"
fre "Trop de champs"
ger "Zu viele Felder"
+ geo "მეტისმეტად ბევრი სვეტი"
greek "Πολύ μεγάλος αριθμός πεδίων"
hindi "बहुत अधिक कॉलम्स"
hun "Tul sok mezo"
@@ -2887,6 +3003,7 @@ ER_TOO_BIG_ROWSIZE 42000
est "Liiga pikk kirje. Kirje maksimumpikkus arvestamata BLOB-tüüpi välju on %ld. Muuda mõned väljad BLOB-tüüpi väljadeks"
fre "Ligne trop grande. Le taille maximale d'une ligne, sauf les BLOBs, est %ld. Changez le type de quelques colonnes en BLOB"
ger "Zeilenlänge zu groß. Die maximale Zeilenlänge für den verwendeten Tabellentyp (ohne BLOB-Felder) beträgt %ld. Einige Felder müssen in BLOB oder TEXT umgewandelt werden"
+ geo "მწკრივის ზომა მეტისმეტად დიდია. მწკრივის მაქსიმალური ზომა გამოყენებული ცხრილის ტიპისთვის, BLOB-ების არჩათვლით, %ld-ს წარმოადგენს. ეს შეიცავს საცავის დამატებით ინფორმაციას. მეტი დეტალებისთვის გადაამოწმეთ დოკუმენტაცია. ზოგიერთ სვეტის ტიპი TEXT-ზე ან BLOB-ზე უნდა შეცვალოთ"
greek "Πολύ μεγάλο μέγεθος εγγραφής. Το μέγιστο μέγεθος εγγραφής, χωρίς να υπολογίζονται τα blobs, είναι %ld. Πρέπει να ορίσετε κάποια πεδία σαν blobs"
hun "Tul nagy sormeret. A maximalis sormeret (nem szamolva a blob objektumokat) %ld. Nehany mezot meg kell valtoztatnia"
ita "Riga troppo grande. La massima grandezza di una riga, non contando i BLOB, e` %ld. Devi cambiare alcuni campi in BLOB"
@@ -2908,6 +3025,7 @@ ER_STACK_OVERRUN
eng "Thread stack overrun: Used: %ld of a %ld stack. Use 'mariadbd --thread_stack=#' to specify a bigger stack if needed"
fre "Débordement de la pile des tâches (Thread stack). Utilisées: %ld pour une pile de %ld. Essayez 'mariadbd --thread_stack=#' pour indiquer une plus grande valeur"
ger "Thread-Stack-Überlauf. Benutzt: %ld von %ld Stack. 'mariadbd --thread_stack=#' verwenden, um bei Bedarf einen größeren Stack anzulegen"
+ geo "ნაკადის სტეკის გადავსება: გამოყენებულია %ld ბაიტი %ld სტეკიდან. უფრო დიდი მნიშვნელობის მისათითებლად, როცა ეს აუცილებელია, გამოიყენეთ 'mariadbd --thread_stack=#'"
greek "Stack overrun στο thread: Used: %ld of a %ld stack. Παρακαλώ χρησιμοποιείστε 'mariadbd --thread_stack=#' για να ορίσετε ένα μεγαλύτερο stack αν χρειάζεται"
hun "Thread verem tullepes: Used: %ld of a %ld stack. Hasznalja a 'mariadbd --thread_stack=#' nagyobb verem definialasahoz"
ita "Thread stack overrun: Usati: %ld di uno stack di %ld. Usa 'mariadbd --thread_stack=#' per specificare uno stack piu` grande"
@@ -2930,6 +3048,7 @@ ER_WRONG_OUTER_JOIN 42000
est "Ristsõltuvus OUTER JOIN klauslis. Kontrolli oma ON tingimusi"
fre "Dépendance croisée dans une clause OUTER JOIN. Vérifiez la condition ON"
ger "OUTER JOIN enthält fehlerhafte Abhängigkeiten. In ON verwendete Bedingungen überprüfen"
+ geo "OUTER JOIN-ში აღმოჩენილია ჯვარედინი დამოკიდებულებები. შეამოწმეთ თქვენი ON-ის პირობები"
greek "Cross dependency βρέθηκε σε OUTER JOIN. Παρακαλώ εξετάστε τις συνθήκες που θέσατε στο ON"
hun "Keresztfuggoseg van az OUTER JOIN-ban. Ellenorizze az ON felteteleket"
ita "Trovata una dipendenza incrociata nella OUTER JOIN. Controlla le condizioni ON"
@@ -2946,6 +3065,7 @@ ER_WRONG_OUTER_JOIN 42000
ER_NULL_COLUMN_IN_INDEX 42000
chi "表处理程序不支持给定索引中的 NULL. 请将列 '%-.192s' 改为 NOT NULL 或使用其他处理程序"
eng "Table handler doesn't support NULL in given index. Please change column '%-.192s' to be NOT NULL or use another handler"
+ geo "ცხრილის დამმუშავებელს მითითებულ ინდექში NULL-ის მხარადაჭერა არ გააჩნია. შეცვალეთ სვეტი '%-.192s', რომ გახდეს NOT NULL ტიპის, ან სხვა დამმუშავებელი გამოიყენეთ"
spa "El manejador de tabla no soporta NULL en índice suministrado. Por favor, cambie la columna '%-.192s' para que sea NOT NULL o utilice otro manejador"
swe "Tabell hanteraren kan inte indexera NULL kolumner för den givna index typen. Ändra '%-.192s' till NOT NULL eller använd en annan hanterare"
ukr "Вказівник таблиці не підтримує NULL у зазначенному індексі. Будь ласка, зменіть стовпчик '%-.192s' на NOT NULL або використайте інший вказівник таблиці."
@@ -2957,6 +3077,7 @@ ER_CANT_FIND_UDF
est "Ei suuda avada funktsiooni '%-.192s'"
fre "Imposible de charger la fonction '%-.192s'"
ger "Kann Funktion '%-.192s' nicht laden"
+ geo "ფუნქციის ('%-.192s') ჩატვირთვა შეუძლებელია"
greek "Δεν είναι δυνατή η διαδικασία load για τη συνάρτηση '%-.192s'"
hindi "फंक्शन '%-.192s' लोड नहीं किया जा सका"
hun "A(z) '%-.192s' fuggveny nem toltheto be"
@@ -2980,6 +3101,7 @@ ER_CANT_INITIALIZE_UDF
est "Ei suuda algväärtustada funktsiooni '%-.192s'; %-.80s"
fre "Impossible d'initialiser la fonction '%-.192s'; %-.80s"
ger "Kann Funktion '%-.192s' nicht initialisieren: %-.80s"
+ geo "ფუნქციის ('%-.192s') ინიციალიზაციის შეცდომა.'%-.80s'"
greek "Δεν είναι δυνατή η έναρξη της συνάρτησης '%-.192s'; %-.80s"
hindi "फंक्शन '%-.192s' को प्रारंभ नहीं किया जा सका; %-.80s"
hun "A(z) '%-.192s' fuggveny nem inicializalhato; %-.80s"
@@ -3003,6 +3125,7 @@ ER_UDF_NO_PATHS
est "Teegi nimes ei tohi olla kataloogi"
fre "Chemin interdit pour les bibliothèques partagées"
ger "Keine Pfade gestattet für Shared Library"
+ geo "გაზიარებული ბიბლიოთეკისთვის ბილიკის მითითება დაუშვებელია"
greek "Δεν βρέθηκαν paths για την shared library"
hun "Nincs ut a megosztott konyvtarakhoz (shared library)"
ita "Non sono ammessi path per le librerie condivisa"
@@ -3025,6 +3148,7 @@ ER_UDF_EXISTS
est "Funktsioon '%-.192s' juba eksisteerib"
fre "La fonction '%-.192s' existe déjà"
ger "Funktion '%-.192s' existiert schon"
+ geo "ფუნქცია '%-.192s' უკვე არსებობს"
greek "Η συνάρτηση '%-.192s' υπάρχει ήδη"
hindi "फंक्शन '%-.192s' पहले से मौजूद है"
hun "A '%-.192s' fuggveny mar letezik"
@@ -3048,6 +3172,7 @@ ER_CANT_OPEN_LIBRARY
est "Ei suuda avada jagatud teeki '%-.192s' (veakood: %d, %-.128s)"
fre "Impossible d'ouvrir la bibliothèque partagée '%-.192s' (errno: %d, %-.128s)"
ger "Kann Shared Library '%-.192s' nicht öffnen (Fehler: %d, %-.128s)"
+ geo "გაზიარებული ბიბლიოთეკის ('%-.192s') გახსნის შეცდომა. (შეცდ. კოდი: %d, '%-.128s')"
greek "Δεν είναι δυνατή η ανάγνωση της shared library '%-.192s' (κωδικός λάθους: %d, %-.128s)"
hun "A(z) '%-.192s' megosztott konyvtar nem hasznalhato (hibakod: %d, %-.128s)"
ita "Impossibile aprire la libreria condivisa '%-.192s' (errno: %d, %-.128s)"
@@ -3073,6 +3198,7 @@ ER_CANT_FIND_DL_ENTRY
est "Ei leia funktsiooni '%-.128s' antud teegis"
fre "Impossible de trouver la fonction '%-.128s' dans la bibliothèque"
ger "Kann Funktion '%-.128s' in der Library nicht finden"
+ geo "ბიბლიოთეკაში სიმბოლო '%-.128s' ვერ ვიპოვე"
greek "Δεν είναι δυνατή η ανεύρεση της συνάρτησης '%-.128s' στην βιβλιοθήκη"
hun "A(z) '%-.128s' fuggveny nem talalhato a konyvtarban"
ita "Impossibile trovare la funzione '%-.128s' nella libreria"
@@ -3095,6 +3221,7 @@ ER_FUNCTION_NOT_DEFINED
est "Funktsioon '%-.192s' ei ole defineeritud"
fre "La fonction '%-.192s' n'est pas définie"
ger "Funktion '%-.192s' ist nicht definiert"
+ geo "ფუნქცია '%-.192s' აღწერილი არაა"
greek "Η συνάρτηση '%-.192s' δεν έχει ορισθεί"
hindi "फंक्शन '%-.192s' की परिभाषा नहीं मिली"
hun "A '%-.192s' fuggveny nem definialt"
@@ -3118,6 +3245,7 @@ ER_HOST_IS_BLOCKED
est "Masin '%-.64s' on blokeeritud hulgaliste ühendusvigade tõttu. Blokeeringu saab tühistada 'mariadb-admin flush-hosts' käsuga"
fre "L'hôte '%-.64s' est bloqué à cause d'un trop grand nombre d'erreur de connexion. Débloquer le par 'mariadb-admin flush-hosts'"
ger "Host '%-.64s' blockiert wegen zu vieler Verbindungsfehler. Aufheben der Blockierung mit 'mariadb-admin flush-hosts'"
+ geo "ჰოსტი '%-.64s' დაიბლოკა მაკავშირებისას მეტისმეტად ბევრი შეცდომის გამო. განბლოკეთ ს ბრძანებით 'mariadb-admin flush-hosts'"
greek "Ο υπολογιστής '%-.64s' έχει αποκλεισθεί λόγω πολλαπλών λαθών σύνδεσης. Προσπαθήστε να διορώσετε με 'mariadb-admin flush-hosts'"
hindi "होस्ट '%-.64s' को कई कनेक्शन में त्रुटियों के कारण ब्लॉक कर दिया गया है; 'mariadb-admin flush-hosts' का इस्तेमाल कर अनब्लॉक करें"
hun "A '%-.64s' host blokkolodott, tul sok kapcsolodasi hiba miatt. Hasznalja a 'mariadb-admin flush-hosts' parancsot"
@@ -3140,6 +3268,7 @@ ER_HOST_NOT_PRIVILEGED
est "Masinal '%-.64s' puudub ligipääs sellele MariaDB serverile"
fre "Le hôte '%-.64s' n'est pas authorisé à se connecter à ce serveur MariaDB"
ger "Host '%-.64s' hat keine Berechtigung, sich mit diesem MariaDB-Server zu verbinden"
+ geo "ჰოსტს '%-.64s' MariaDB-ის ამ სერვერთან მიერთება აკრძალული აქვს"
greek "Ο υπολογιστής '%-.64s' δεν έχει δικαίωμα σύνδεσης με τον MariaDB server"
hindi "होस्ट '%-.64s' को इस MariaDB सर्वर से कनेक्ट करने के लिए अनुमति नहीं है"
hun "A '%-.64s' host szamara nem engedelyezett a kapcsolodas ehhez a MariaDB szerverhez"
@@ -3162,6 +3291,7 @@ ER_PASSWORD_ANONYMOUS_USER 42000
est "Te kasutate MariaDB-i anonüümse kasutajana, kelledel pole parooli muutmise õigust"
fre "Vous utilisez un utilisateur anonyme et les utilisateurs anonymes ne sont pas autorisés à changer les mots de passe"
ger "Sie benutzen MariaDB als anonymer Benutzer und dürfen daher keine Passwörter ändern"
+ geo "MariaDB-ს ანონიმური მომხმარებლით იყენებთ და ანონიმურ მომხმარებლებს მომხმარებლების პარამეტრები შეცვლის უფლება არ გააჩნიათ"
greek "Χρησιμοποιείτε την MariaDB σαν anonymous user και έτσι δεν μπορείτε να αλλάξετε τα passwords άλλων χρηστών"
hindi "आप MariaDB का उपयोग एक बेनाम यूज़र की तरह कर रहे हैं; बेनाम यूज़र्स को 'यूज़र सेटिंग्स' बदलने की अनुमति नहीं है"
hun "Nevtelen (anonymous) felhasznalokent nem negedelyezett a jelszovaltoztatas"
@@ -3184,6 +3314,7 @@ ER_PASSWORD_NOT_ALLOWED 42000
est "Teiste paroolide muutmiseks on nõutav tabelite muutmisõigus 'mysql' andmebaasis"
fre "Vous devez avoir le privilège update sur les tables de la base de donnée mysql pour pouvoir changer les mots de passe des autres"
ger "Sie benötigen die Berechtigung zum Aktualisieren von Tabellen in der Datenbank 'mysql', um die Passwörter anderer Benutzer ändern zu können"
+ geo "სხვებისთვის პაროლების შესაცვლელდ mysql მონაცემთა ბაზაში ცხრილების განახლების უფლება უნდა გქონდეთ"
greek "Πρέπει να έχετε δικαίωμα διόρθωσης πινάκων (update) στη βάση δεδομένων mysql για να μπορείτε να αλλάξετε τα passwords άλλων χρηστών"
hun "Onnek tabla-update joggal kell rendelkeznie a mysql adatbazisban masok jelszavanak megvaltoztatasahoz"
ita "E` necessario il privilegio di update sulle tabelle del database mysql per cambiare le password per gli altri utenti"
@@ -3205,6 +3336,7 @@ ER_PASSWORD_NO_MATCH 28000
est "Ei leia vastavat kirjet kasutajate tabelis"
fre "Impossible de trouver un enregistrement correspondant dans la table user"
ger "Kann keinen passenden Datensatz in Tabelle 'user' finden"
+ geo "მომხმარებლის ცხრილში შესატყვისი მწკრივი ვერ ვიპოვე"
greek "Δεν είναι δυνατή η ανεύρεση της αντίστοιχης εγγραφής στον πίνακα των χρηστών"
hindi "यूज़र टेबल में रिकॉर्ड नहीं मिला"
hun "Nincs megegyezo sor a user tablaban"
@@ -3227,6 +3359,7 @@ ER_UPDATE_INFO
est "Sobinud kirjeid: %ld Muudetud: %ld Hoiatusi: %ld"
fre "Enregistrements correspondants: %ld Modifiés: %ld Warnings: %ld"
ger "Datensätze gefunden: %ld Geändert: %ld Warnungen: %ld"
+ geo "ემთხვევა მწკრივები: %ld შეიცვალა: %ld გაფრთხილებები: %ld"
hun "Megegyezo sorok szama: %ld Valtozott: %ld Warnings: %ld"
ita "Rows riconosciute: %ld Cambiate: %ld Warnings: %ld"
jpn "該当した行: %ld 変更: %ld 警告: %ld"
@@ -3247,6 +3380,7 @@ ER_CANT_CREATE_THREAD
est "Ei suuda luua uut lõime (veakood %M). Kui mälu ei ole otsas, on tõenäoliselt tegemist operatsioonisüsteemispetsiifilise veaga"
fre "Impossible de créer une nouvelle tâche (errno %M). S'il reste de la mémoire libre, consultez le manual pour trouver un éventuel bug dépendant de l'OS"
ger "Kann keinen neuen Thread erzeugen (Fehler: %M). Sollte noch Speicher verfügbar sein, bitte im Handbuch wegen möglicher Fehler im Betriebssystem nachschlagen"
+ geo "ახალი ნაკადის შექმნა შეუძლებელია (შეცდ. კოდი %M). თუ მეხსიერება ნამდვილად საკმარისია, გადაავლეთ თვალი დოკუმენტაციას, გადაამოწმეთ ოს-ზე დამოკიდებული შეცდომის არსებობა"
hun "Uj thread letrehozasa nem lehetseges (Hibakod: %M). Amenyiben van meg szabad memoria, olvassa el a kezikonyv operacios rendszerfuggo hibalehetosegekrol szolo reszet"
ita "Impossibile creare un nuovo thread (errno %M). Se non ci sono problemi di memoria disponibile puoi consultare il manuale per controllare possibili problemi dipendenti dal SO"
jpn "新規にスレッドを作成できません。(エラー番号 %M) もしも使用可能メモリーの不足でなければ、OS依存のバグである可能性があります。"
@@ -3269,6 +3403,7 @@ ER_WRONG_VALUE_COUNT_ON_ROW 21S01
eng "Column count doesn't match value count at row %lu"
est "Tulpade hulk erineb väärtuste hulgast real %lu"
ger "Anzahl der Felder stimmt nicht mit der Anzahl der Werte in Zeile %lu überein"
+ geo "სვეტების რაოდენობა ჩანაწერში %lu მითითებულ რაოდენობას არ ემთხვევა"
hun "Az oszlopban talalhato ertek nem egyezik meg a %lu sorban szamitott ertekkel"
ita "Il numero delle colonne non corrisponde al conteggio alla riga %lu"
jpn "%lu 行目で、列の数が値の数と一致しません。"
@@ -3289,6 +3424,7 @@ ER_CANT_REOPEN_TABLE
est "Ei suuda taasavada tabelit '%-.192s'"
fre "Impossible de réouvrir la table: '%-.192s"
ger "Kann Tabelle'%-.192s' nicht erneut öffnen"
+ geo "ცხრილის თავიდან გახსნის შეცდომა: '%-.192s'"
hindi "टेबल '%-.192s' फिर से खोल नहीं सकते"
hun "Nem lehet ujra-megnyitni a tablat: '%-.192s"
ita "Impossibile riaprire la tabella: '%-.192s'"
@@ -3314,6 +3450,7 @@ ER_INVALID_USE_OF_NULL 22004
est "NULL väärtuse väärkasutus"
fre "Utilisation incorrecte de la valeur NULL"
ger "Unerlaubte Verwendung eines NULL-Werts"
+ geo "NULL მნიშვნელობის არასწორი გამოყენება"
hindi "NULL मान का अवैध उपयोग"
hun "A NULL ervenytelen hasznalata"
ita "Uso scorretto del valore NULL"
@@ -3335,6 +3472,7 @@ ER_REGEXP_ERROR 42000
est "regexp tagastas vea: %s"
fre "Erreur '%s' provenant de regexp"
ger "Regexp Fehler %s"
+ geo "რეგულარული გამოსახულების შეცდომა '%s'"
hindi "regexp में '%s' त्रुटि हुई"
hun "'%s' hiba a regularis kifejezes hasznalata soran (regexp)"
ita "Errore '%s' da regexp"
@@ -3356,6 +3494,7 @@ ER_MIX_OF_GROUP_FUNC_AND_FIELDS 42000
est "GROUP tulpade (MIN(),MAX(),COUNT()...) kooskasutamine tavaliste tulpadega ilma GROUP BY klauslita ei ole lubatud"
fre "Mélanger les colonnes GROUP (MIN(),MAX(),COUNT()...) avec des colonnes normales est interdit s'il n'y a pas de clause GROUP BY"
ger "Das Vermischen von GROUP-Feldern (MIN(),MAX(),COUNT()...) mit Nicht-GROUP-Feldern ist nicht zulässig, wenn keine GROUP-BY-Klausel vorhanden ist"
+ geo "GROUP-ის სვეტების (MIN(),MAX(),COUNT(),...) შერევა არა-GROUP-ის სვეტებთან დაუშვებელია, თუ თუ გამოსახულებაში არსებობს GROUP BY"
hun "A GROUP mezok (MIN(),MAX(),COUNT()...) kevert hasznalata nem lehetseges GROUP BY hivatkozas nelkul"
ita "Il mescolare funzioni di aggregazione (MIN(),MAX(),COUNT()...) e non e` illegale se non c'e` una clausula GROUP BY"
jpn "GROUP BY句が無い場合、集計関数(MIN(),MAX(),COUNT(),...)と通常の列を同時に使用できません。"
@@ -3376,6 +3515,7 @@ ER_NONEXISTING_GRANT 42000
est "Sellist õigust ei ole defineeritud kasutajale '%-.48s' masinast '%-.64s'"
fre "Un tel droit n'est pas défini pour l'utilisateur '%-.48s' sur l'hôte '%-.64s'"
ger "Für Benutzer '%-.48s' auf Host '%-.64s' gibt es keine solche Berechtigung"
+ geo "მომხმარებლისთვის '%-.48s' ჰოსტზე '%-.64s' ასეთი უფლებები აღწერილი არაა"
hun "A '%-.48s' felhasznalonak nincs ilyen joga a '%-.64s' host-on"
ita "GRANT non definita per l'utente '%-.48s' dalla macchina '%-.64s'"
jpn "ユーザー '%-.48s' (ホスト '%-.64s' 上) は許可されていません。"
@@ -3397,6 +3537,7 @@ ER_TABLEACCESS_DENIED_ERROR 42000
est "%-.100T käsk ei ole lubatud kasutajale '%s'@'%s' tabelis %`s.%`s"
fre "La commande '%-.100T' est interdite à l'utilisateur: '%s'@'%s' sur la table %`s.%`s"
ger "%-.100T Befehl nicht erlaubt für Benutzer '%s'@'%s' auf Tabelle %`s.%`s"
+ geo "%-.100T ბრძანება უარყოფილია მომხმარებლისთვის '%s'@'%s' ცხრილისთვის %`s.%`s"
hun "%-.100T parancs a '%s'@'%s' felhasznalo szamara nem engedelyezett a %`s.%`s tablaban"
ita "Comando %-.100T negato per l'utente: '%s'@'%s' sulla tabella %`s.%`s"
jpn "コマンド %-.100T は ユーザー '%s'@'%s' ,テーブル %`s.%`s に対して許可されていません"
@@ -3416,6 +3557,7 @@ ER_COLUMNACCESS_DENIED_ERROR 42000
est "%-.32s käsk ei ole lubatud kasutajale '%s'@'%s' tulbale '%-.192s' tabelis '%-.192s'"
fre "La commande '%-.32s' est interdite à l'utilisateur: '%s'@'%s' sur la colonne '%-.192s' de la table '%-.192s'"
ger "%-.32s Befehl nicht erlaubt für Benutzer '%s'@'%s' und Feld '%-.192s' in Tabelle '%-.192s'"
+ geo "ბრძანება %-.32s უარყოფილია მომხმარებლისთვის '%s'@'%s' სვეტისთვის '%-.192s' ცხრილში '%-.192s'"
hun "%-.32s parancs a '%s'@'%s' felhasznalo szamara nem engedelyezett a '%-.192s' mezo eseten a '%-.192s' tablaban"
ita "Comando %-.32s negato per l'utente: '%s'@'%s' sulla colonna '%-.192s' della tabella '%-.192s'"
jpn "コマンド %-.32s は ユーザー '%s'@'%s'\n カラム '%-.192s' テーブル '%-.192s' に対して許可されていません"
@@ -3436,6 +3578,7 @@ ER_ILLEGAL_GRANT_FOR_TABLE 42000
est "Vigane GRANT/REVOKE käsk. Tutvu kasutajajuhendiga"
fre "Commande GRANT/REVOKE incorrecte. Consultez le manuel"
ger "Unzulässiger GRANT- oder REVOKE-Befehl. Verfügbare Berechtigungen sind im Handbuch aufgeführt"
+ geo "არასწორი GRANT/REVOKE ბრძანება. გამოყენებადი პრივილეგიების სიის მოსაძებნად სახელმძღვანელოს მიმართეთ"
greek "Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used"
hun "Ervenytelen GRANT/REVOKE parancs. Kerem, nezze meg a kezikonyvben, milyen jogok lehetsegesek"
ita "Comando GRANT/REVOKE illegale. Prego consultare il manuale per sapere quali privilegi possono essere usati"
@@ -3461,6 +3604,7 @@ ER_GRANT_WRONG_HOST_OR_USER 42000
est "Masina või kasutaja nimi GRANT lauses on liiga pikk"
fre "L'hôte ou l'utilisateur donné en argument à GRANT est trop long"
ger "Das Host- oder User-Argument für GRANT ist zu lang"
+ geo "ჰოსტის ან მომხმარებლის არგუმენტები GRANT-სთვის ძალიან გრძელია"
hindi "GRANT के लिए होस्ट या यूज़र आर्गुमेंट बहुत लंबा है"
hun "A host vagy felhasznalo argumentuma tul hosszu a GRANT parancsban"
ita "L'argomento host o utente per la GRANT e` troppo lungo"
@@ -3482,6 +3626,7 @@ ER_NO_SUCH_TABLE 42S02
est "Tabelit '%-.192s.%-.192s' ei eksisteeri"
fre "La table '%-.192s.%-.192s' n'existe pas"
ger "Tabelle '%-.192s.%-.192s' existiert nicht"
+ geo "ცხრილი '%-.192s.%-.192s' არ არსებობს"
hindi "टेबल '%-.192s.%-.192s' मौजूद नहीं है"
hun "A '%-.192s.%-.192s' tabla nem letezik"
ita "La tabella '%-.192s.%-.192s' non esiste"
@@ -3507,6 +3652,7 @@ ER_NONEXISTING_TABLE_GRANT 42000
est "Sellist õigust ei ole defineeritud kasutajale '%-.48s' masinast '%-.64s' tabelile '%-.192s'"
fre "Un tel droit n'est pas défini pour l'utilisateur '%-.48s' sur l'hôte '%-.64s' sur la table '%-.192s'"
ger "Eine solche Berechtigung ist für User '%-.48s' auf Host '%-.64s' an Tabelle '%-.192s' nicht definiert"
+ geo "ასეთი უფლებები აღწერილი არაა მომხმარებლისთვის '%-.48s' ჰოსტზე '%-.64s' ცხრილზე '%-.192s'"
hun "A '%-.48s' felhasznalo szamara a '%-.64s' host '%-.192s' tablajaban ez a parancs nem engedelyezett"
ita "GRANT non definita per l'utente '%-.48s' dalla macchina '%-.64s' sulla tabella '%-.192s'"
jpn "ユーザー '%-.48s' (ホスト '%-.64s' 上) の表 '%-.192s' への権限は定義されていません。"
@@ -3527,6 +3673,7 @@ ER_NOT_ALLOWED_COMMAND 42000
est "Antud käsk ei ole lubatud käesolevas MariaDB versioonis"
fre "Cette commande n'existe pas dans cette version de MariaDB"
ger "Der verwendete Befehl ist in dieser MariaDB-Version nicht zulässig"
+ geo "გამოყენებული ბრძანება MariaDB-ის ამ ვერსიაში დაუსვებელია"
hindi "यह कमांड इस MariaDB संस्करण के साथ इस्तेमाल नहीं किया जा सकता है"
hun "A hasznalt parancs nem engedelyezett ebben a MariaDB verzioban"
ita "Il comando utilizzato non e` supportato in questa versione di MariaDB"
@@ -3548,6 +3695,7 @@ ER_SYNTAX_ERROR 42000
est "Viga SQL süntaksis"
fre "Erreur de syntaxe"
ger "Fehler in der SQL-Syntax. Bitte die korrekte Syntax im Handbuch nachschlagen"
+ geo "SQL-ის სინტაქსის შეცდომა. სწორი სინტაქსის შესასწავლად თქვენი MariaDB-ის სერვერის ვერსიის შესაბამისი სახელმძღვანელო გამოიყენეთ"
greek "You have an error in your SQL syntax"
hindi "आपके SQL सिंटेक्स मैं गलती है; सही सिंटेक्स के लिए अपने MariaDB सर्वर संस्करण के मैन्युअल की सहायता लें"
hun "Szintaktikai hiba"
@@ -3574,6 +3722,7 @@ ER_DELAYED_CANT_CHANGE_LOCK
est "INSERT DELAYED lõim ei suutnud saada soovitud lukku tabelile %-.192s"
fre "La tâche 'delayed insert' n'a pas pu obtenir le verrou démandé sur la table %-.192s"
ger "Verzögerter (DELAYED) Einfüge-Thread konnte die angeforderte Sperre für Tabelle '%-.192s' nicht erhalten"
+ geo "დაყოვნებული ჩამატების ნაკადმა მოთხოვნილი ბლოკი ცხრილზე %-.192s ვერ მიიღო"
hun "A kesleltetett beillesztes (delayed insert) thread nem kapott zatolast a %-.192s tablahoz"
ita "Il thread di inserimento ritardato non riesce ad ottenere il lock per la tabella %-.192s"
jpn "'Delayed insert'スレッドが表 '%-.192s' のロックを取得できませんでした。"
@@ -3593,6 +3742,7 @@ ER_TOO_MANY_DELAYED_THREADS
eng "Too many delayed threads in use"
est "Liiga palju DELAYED lõimesid kasutusel"
fre "Trop de tâche 'delayed' en cours"
+ geo "გამოიყენება დაყოვნებული ჩამატების მეტისმეტად ბევრი ნაკადი"
ger "Zu viele verzögerte (DELAYED) Threads in Verwendung"
hindi "बहुत से DELAYED थ्रेड्स उपयोग में हैं"
hun "Tul sok kesletetett thread (delayed)"
@@ -3615,6 +3765,7 @@ ER_ABORTING_CONNECTION 08S01
est "Ühendus katkestatud %ld andmebaasile: '%-.192s' kasutajale: '%-.48s' (%-.64s)"
fre "Connection %ld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' (%-.64s)"
ger "Abbruch der Verbindung %ld zur Datenbank '%-.192s'. Benutzer: '%-.48s' (%-.64s)"
+ geo "გაუქმდა კავშირი %ld ბაზამდე: '%-.192s' მომხმარებელი: '%-.48s' (%-.64s)"
hun "Megszakitott kapcsolat %ld db: '%-.192s' adatbazishoz, felhasznalo: '%-.48s' (%-.64s)"
ita "Interrotta la connessione %ld al db: '%-.192s' utente: '%-.48s' (%-.64s)"
jpn "接続 %ld が中断されました。データベース: '%-.192s' ユーザー: '%-.48s' (%-.64s)"
@@ -3639,6 +3790,7 @@ ER_NET_PACKET_TOO_LARGE 08S01
est "Saabus suurem pakett kui lubatud 'max_allowed_packet' muutujaga"
fre "Paquet plus grand que 'max_allowed_packet' reçu"
ger "Empfangenes Paket ist größer als 'max_allowed_packet' Bytes"
+ geo "მიღებული პაკეტი 'max_allowed_packet'-ზე დიდია"
hindi "'max_allowed_packet' से भी बड़ा एक पैकेट मिला"
hun "A kapott csomag nagyobb, mint a maximalisan engedelyezett: 'max_allowed_packet'"
ita "Ricevuto un pacchetto piu` grande di 'max_allowed_packet'"
@@ -3660,6 +3812,7 @@ ER_NET_READ_ERROR_FROM_PIPE 08S01
est "Viga ühendustoru lugemisel"
fre "Erreur de lecture reçue du pipe de connexion"
ger "Lese-Fehler bei einer Verbindungs-Pipe"
+ geo "კავშირის ნაკადიდან (connection pipe) მონაცემების წაკითხვის შეცდომა"
hindi "कनेक्शन पाइप से एक READ त्रुटि हुई"
hun "Olvasasi hiba a kapcsolat soran"
ita "Rilevato un errore di lettura dalla pipe di connessione"
@@ -3681,6 +3834,7 @@ ER_NET_FCNTL_ERROR 08S01
est "fcntl() tagastas vea"
fre "Erreur reçue de fcntl() "
ger "fcntl() lieferte einen Fehler"
+ geo "მიღებულია შეცდომა ფუნქციიდან fnctl()"
hindi "fcntl() से एक त्रुटि हुई"
hun "Hiba a fcntl() fuggvenyben"
ita "Rilevato un errore da fcntl()"
@@ -3702,6 +3856,7 @@ ER_NET_PACKETS_OUT_OF_ORDER 08S01
est "Paketid saabusid vales järjekorras"
fre "Paquets reçus dans le désordre"
ger "Pakete nicht in der richtigen Reihenfolge empfangen"
+ geo "პაკეტების მიღების მიმდევრობა არასწორია"
hindi "पैकेट्स क्रम में नहीं प्राप्त हुए"
hun "Helytelen sorrendben erkezett adatcsomagok"
ita "Ricevuti pacchetti non in ordine"
@@ -3723,6 +3878,7 @@ ER_NET_UNCOMPRESS_ERROR 08S01
est "Viga andmepaketi lahtipakkimisel"
fre "Impossible de décompresser le paquet reçu"
ger "Kommunikationspaket lässt sich nicht entpacken"
+ geo "კომუნიკაციის პაკეტის გაშლის შეცდომა"
hindi "संचार पैकेट UNCOMPRESS नहीं कर सके"
hun "A kommunikacios adatcsomagok nem tomorithetok ki"
ita "Impossibile scompattare i pacchetti di comunicazione"
@@ -3744,6 +3900,7 @@ ER_NET_READ_ERROR 08S01
est "Viga andmepaketi lugemisel"
fre "Erreur de lecture des paquets reçus"
ger "Fehler beim Lesen eines Kommunikationspakets"
+ geo "შეცდომა კომუნიკაციის პაკეტების წაკითხვისას"
hindi "संचार पैकेट्स पढ़ते समय एक त्रुटि हुई"
hun "HIba a kommunikacios adatcsomagok olvasasa soran"
ita "Rilevato un errore ricevendo i pacchetti di comunicazione"
@@ -3765,6 +3922,7 @@ ER_NET_READ_INTERRUPTED 08S01
est "Kontrollaja ületamine andmepakettide lugemisel"
fre "Timeout en lecture des paquets reçus"
ger "Zeitüberschreitung beim Lesen eines Kommunikationspakets"
+ geo "კომუნიკაციის პაკეტების წაკითხვის მოლოდინის ვადა გავიდა"
hindi "संचार पैकेट्स पढ़ने के दौरान टाइमआउट"
hun "Idotullepes a kommunikacios adatcsomagok olvasasa soran"
ita "Rilevato un timeout ricevendo i pacchetti di comunicazione"
@@ -3786,6 +3944,7 @@ ER_NET_ERROR_ON_WRITE 08S01
est "Viga andmepaketi kirjutamisel"
fre "Erreur d'écriture des paquets envoyés"
ger "Fehler beim Schreiben eines Kommunikationspakets"
+ geo "შეცდომა კომუნიკაციის პაკეტების ჩაწერისას"
hindi "संचार पैकेट्स लिखते समय एक त्रुटि हुई"
hun "Hiba a kommunikacios csomagok irasa soran"
ita "Rilevato un errore inviando i pacchetti di comunicazione"
@@ -3807,6 +3966,7 @@ ER_NET_WRITE_INTERRUPTED 08S01
est "Kontrollaja ületamine andmepakettide kirjutamisel"
fre "Timeout d'écriture des paquets envoyés"
ger "Zeitüberschreitung beim Schreiben eines Kommunikationspakets"
+ geo "კომუნიკაციის პაკეტების ჩაწერის მოლოდინის ვადა ამოიწურა"
hindi "संचार पैकेट्स लिखने के दौरान टाइमआउट"
hun "Idotullepes a kommunikacios csomagok irasa soran"
ita "Rilevato un timeout inviando i pacchetti di comunicazione"
@@ -3828,6 +3988,7 @@ ER_TOO_LONG_STRING 42000
est "Tulemus on pikem kui lubatud 'max_allowed_packet' muutujaga"
fre "La chaîne résultat est plus grande que 'max_allowed_packet'"
ger "Ergebnis-String ist länger als 'max_allowed_packet' Bytes"
+ geo "შედეგად მიღებული სტრიქონი 'max_allowed_packet' ბაიტზე გრძელია"
hindi "रिजल्ट स्ट्रिंग 'max_allowed_packet' से लंबा है"
hun "Ez eredmeny sztring nagyobb, mint a lehetseges maximum: 'max_allowed_packet'"
ita "La stringa di risposta e` piu` lunga di 'max_allowed_packet'"
@@ -3849,6 +4010,7 @@ ER_TABLE_CANT_HANDLE_BLOB 42000
est "Valitud tabelitüüp (%s) ei toeta BLOB/TEXT tüüpi välju"
fre "Ce type de table (%s) ne supporte pas les colonnes BLOB/TEXT"
ger "Der verwendete Tabellentyp (%s) unterstützt keine BLOB- und TEXT-Felder"
+ geo "საცავის ძრავას %s BLOB/TEXT ტიპის სვეტების მხარდაჭერა არ გააჩნია"
hindi "स्टोरेज इंजन %s BLOB/TEXT कॉलम्स को सपोर्ट नहीं करता"
hun "A hasznalt tabla tipus (%s) nem tamogatja a BLOB/TEXT mezoket"
ita "Il tipo di tabella usata (%s) non supporta colonne di tipo BLOB/TEXT"
@@ -3869,6 +4031,7 @@ ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 42000
est "Valitud tabelitüüp (%s) ei toeta AUTO_INCREMENT tüüpi välju"
fre "Ce type de table (%s) ne supporte pas les colonnes AUTO_INCREMENT"
ger "Der verwendete Tabellentyp (%s) unterstützt keine AUTO_INCREMENT-Felder"
+ geo "საცავის ძრავას (%s) AUTO_INCREMENT ტიპის სვეტების მხარდაჭერა არ გააჩნია"
hindi "स्टोरेज इंजन %s AUTO_INCREMENT कॉलम्स को सपोर्ट नहीं करता"
hun "A hasznalt tabla tipus (%s) nem tamogatja az AUTO_INCREMENT tipusu mezoket"
ita "Il tipo di tabella usata (%s) non supporta colonne di tipo AUTO_INCREMENT"
@@ -3889,6 +4052,7 @@ ER_DELAYED_INSERT_TABLE_LOCKED
est "INSERT DELAYED ei saa kasutada tabeli '%-.192s' peal, kuna see on lukustatud LOCK TABLES käsuga"
fre "INSERT DELAYED ne peut être utilisé avec la table '%-.192s', car elle est verrouée avec LOCK TABLES"
ger "INSERT DELAYED kann für Tabelle '%-.192s' nicht verwendet werden, da sie mit LOCK TABLES gesperrt ist"
+ geo "INSERT DELAYED-ს ცხრილზე '%-.192s' ვერ გამოიყენებთ, რადგან ის LOCK TABLES-ითაა დაბლოკილი"
greek "INSERT DELAYED can't be used with table '%-.192s', because it is locked with LOCK TABLES"
hun "Az INSERT DELAYED nem hasznalhato a '%-.192s' tablahoz, mert a tabla zarolt (LOCK TABLES)"
ita "L'inserimento ritardato (INSERT DELAYED) non puo` essere usato con la tabella '%-.192s', perche` soggetta a lock da 'LOCK TABLES'"
@@ -3914,6 +4078,7 @@ ER_WRONG_COLUMN_NAME 42000
est "Vigane tulba nimi '%-.100s'"
fre "Nom de colonne '%-.100s' incorrect"
ger "Falscher Spaltenname '%-.100s'"
+ geo "სვეტის ('%-.100s') სახელი არასწორია"
hindi "कॉलम नाम '%-.100s' गलत है"
hun "Ervenytelen mezonev: '%-.100s'"
ita "Nome colonna '%-.100s' non corretto"
@@ -3930,6 +4095,7 @@ ER_WRONG_KEY_COLUMN 42000
chi "存储引擎 %s 不能给 %`s 列建索引"
eng "The storage engine %s can't index column %`s"
ger "Die Speicher-Engine %s kann die Spalte %`s nicht indizieren"
+ geo "საცავის ძრავას (%s) სვეტზე (%`s) ინდექსის დადება არ შეუძლია"
hindi "स्टोरेज इंजन %s, कॉलम %`s को इंडेक्स नहीं कर सकता"
rus "Обработчик таблиц %s не может проиндексировать столбец %`s"
spa "El motor de almacenaje %s no puede indizar la columna %`s"
@@ -3942,6 +4108,7 @@ ER_WRONG_MRG_TABLE
est "Kõik tabelid MERGE tabeli määratluses ei ole identsed"
fre "Toutes les tables de la table de type MERGE n'ont pas la même définition"
ger "Nicht alle Tabellen in der MERGE-Tabelle sind gleich definiert"
+ geo "MERGE-ში ყველა ცხრილი ერთნაირად არაა აღწერილი"
hun "A MERGE tablaban talalhato tablak definicioja nem azonos"
ita "Non tutte le tabelle nella tabella di MERGE sono definite in maniera identica"
jpn "MERGE表の構成表がオープンできません。列定義が異なるか、MyISAM表ではないか、存在しません。"
@@ -3966,6 +4133,7 @@ ER_DUP_UNIQUE 23000
est "Ei suuda kirjutada tabelisse '%-.192s', kuna see rikub ühesuse kitsendust"
fre "Écriture impossible à cause d'un index UNIQUE sur la table '%-.192s'"
ger "Schreiben in Tabelle '%-.192s' nicht möglich wegen einer Eindeutigkeitsbeschränkung (unique constraint)"
+ geo "ცხრილში '%-.192s' უნიკალური გასაღების შეზღუდვის გამო ჩაწერა შეუძლებელია"
hun "A '%-.192s' nem irhato, az egyedi mezok miatt"
ita "Impossibile scrivere nella tabella '%-.192s' per limitazione di unicita`"
jpn "一意性制約違反のため、表 '%-.192s' に書き込めません。"
@@ -3985,6 +4153,7 @@ ER_BLOB_KEY_WITHOUT_LENGTH 42000
est "BLOB-tüüpi tulp '%-.192s' on kasutusel võtmes ilma pikkust määratlemata"
fre "La colonne '%-.192s' de type BLOB est utilisée dans une définition d'index sans longueur d'index"
ger "BLOB- oder TEXT-Spalte '%-.192s' wird in der Schlüsseldefinition ohne Schlüssellängenangabe verwendet"
+ geo "სვეტი ტიპით BLOB '%-.192s' მითითებულია გასაღების აღწერაში გასაღების სიგრძის მითითების გარეშე"
greek "BLOB column '%-.192s' used in key specification without a key length"
hun "BLOB mezo '%-.192s' hasznalt a mezo specifikacioban, a mezohossz megadasa nelkul"
ita "La colonna '%-.192s' di tipo BLOB e` usata in una chiave senza specificarne la lunghezza"
@@ -4010,6 +4179,7 @@ ER_PRIMARY_CANT_HAVE_NULL 42000
est "Kõik PRIMARY KEY peavad olema määratletud NOT NULL piiranguga; vajadusel kasuta UNIQUE tüüpi võtit"
fre "Toutes les parties d'un index PRIMARY KEY doivent être NOT NULL; Si vous avez besoin d'un NULL dans l'index, utilisez un index UNIQUE"
ger "Alle Teile eines PRIMARY KEY müssen als NOT NULL definiert sein. Wenn NULL in einem Schlüssel benötigt wird, muss ein UNIQUE-Schlüssel verwendet werden"
+ geo "PRIMARY KEY-ის ყველა ნაწილი NOT NULL პარამეტრით უნდა იყოს აღწერილი. თუ გასაღებში NULL გჭირდებათ, UNIQUE გამოიყენეთ"
hindi "PRIMARY KEY के सभी भागों को NOT NULL होना चाहिए; यदि आपको एक KEY में NULL की जरूरत है, तो UNIQUE का उपयोग करें"
hun "Az elsodleges kulcs teljes egeszeben csak NOT NULL tipusu lehet; Ha NULL mezot szeretne a kulcskent, hasznalja inkabb a UNIQUE-ot"
ita "Tutte le parti di una chiave primaria devono essere dichiarate NOT NULL; se necessitano valori NULL nelle chiavi utilizzare UNIQUE"
@@ -4030,6 +4200,7 @@ ER_TOO_MANY_ROWS 42000
est "Tulemis oli rohkem kui üks kirje"
fre "Le résultat contient plus d'un enregistrement"
ger "Ergebnis besteht aus mehr als einer Zeile"
+ geo "შედეგი ერთ სტრიქონზე მეტს შეიცავს"
hindi "परिणाम एक से अधिक पंक्ति का है"
hun "Az eredmeny tobb, mint egy sort tartalmaz"
ita "Il risultato consiste di piu` di una riga"
@@ -4050,6 +4221,7 @@ ER_REQUIRES_PRIMARY_KEY 42000
est "Antud tabelitüüp nõuab primaarset võtit"
fre "Ce type de table nécessite une clé primaire (PRIMARY KEY)"
ger "Dieser Tabellentyp benötigt einen Primärschlüssel (PRIMARY KEY)"
+ geo "ცხრილის ეს ტიპი ძირითად გასაღებს (PRIMARY KEY) მოითხოვს"
hindi "इस प्रकार के टेबल को एक PRIMARY KEY की आवश्यकता है"
hun "Az adott tablatipushoz elsodleges kulcs hasznalata kotelezo"
ita "Questo tipo di tabella richiede una chiave primaria"
@@ -4070,6 +4242,7 @@ ER_NO_RAID_COMPILED
est "Antud MariaDB versioon on kompileeritud ilma RAID toeta"
fre "Cette version de MariaDB n'est pas compilée avec le support RAID"
ger "Diese MariaDB-Version ist nicht mit RAID-Unterstützung kompiliert"
+ geo "MariaDB-ის ეს ვერსია RAID-ის მხარდაჭერით არაა აგებული"
hindi "MariaDB का यह संस्करण RAID सपोर्ट के साथ कॉम्पाईल्ड नहीं है"
hun "Ezen leforditott MariaDB verzio nem tartalmaz RAID support-ot"
ita "Questa versione di MariaDB non e` compilata con il supporto RAID"
@@ -4090,6 +4263,7 @@ ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
est "Katse muuta tabelit turvalises rezhiimis ilma WHERE klauslita"
fre "Vous êtes en mode 'safe update' et vous essayez de faire un UPDATE sans clause WHERE utilisant un index"
ger "MariaDB läuft im sicheren Aktualisierungsmodus (safe update mode). Sie haben versucht, eine Tabelle zu aktualisieren, ohne in der WHERE-Klausel ein KEY-Feld anzugeben"
+ geo "იყენებთ უსაფრთხო განახლებების რეჟიმს და სცადეთ ცხრილი WHERE-ის, რომელიც KEY სვეტს შეიცავს, გარეშე გაგეახლებინათ"
hun "On a biztonsagos update modot hasznalja, es WHERE that uses a KEY column"
ita "In modalita` 'safe update' si e` cercato di aggiornare una tabella senza clausola WHERE su una chiave"
jpn "'safe update mode'で、索引を利用するWHERE句の無い更新処理を実行しようとしました。"
@@ -4108,6 +4282,7 @@ ER_KEY_DOES_NOT_EXISTS 42000 S1009
est "Võti '%-.192s' ei eksisteeri tabelis '%-.192s'"
fre "L'index '%-.192s' n'existe pas sur la table '%-.192s'"
ger "Schlüssel '%-.192s' existiert in der Tabelle '%-.192s' nicht"
+ geo "გასაღები '%-.192s' არ არსებობს ცხრილში '%-.192s'"
hindi "KEY '%-.192s', टेबल '%-.192s' में मौजूद नहीं है"
hun "A '%-.192s' kulcs nem letezik a '%-.192s' tablaban"
ita "La chiave '%-.192s' non esiste nella tabella '%-.192s'"
@@ -4127,6 +4302,7 @@ ER_CHECK_NO_SUCH_TABLE 42000
est "Ei suuda avada tabelit"
fre "Impossible d'ouvrir la table"
ger "Kann Tabelle nicht öffnen"
+ geo "ცხრილის გახსნის შეცდომა"
hindi "टेबल नहीं खुल सकता है"
hun "Nem tudom megnyitni a tablat"
ita "Impossibile aprire la tabella"
@@ -4146,6 +4322,7 @@ ER_CHECK_NOT_IMPLEMENTED 42000
est "Antud tabelitüüp ei toeta %s käske"
fre "Ce type de table ne supporte pas les %s"
ger "Die Speicher-Engine für diese Tabelle unterstützt kein %s"
+ geo "ცხრილის საცავის ზრავს %s-ის მხარდაჭერა არ გააჩნია"
greek "The handler for the table doesn't support %s"
hindi "इस टेबल का स्टोरेज इंजन '%s' को सपोर्ट नहीं करता"
hun "A tabla kezeloje (handler) nem tamogatja az %s"
@@ -4172,6 +4349,7 @@ ER_CANT_DO_THIS_DURING_AN_TRANSACTION 25000
est "Seda käsku ei saa kasutada transaktsiooni sees"
fre "Vous n'êtes pas autorisé à exécute cette commande dans une transaction"
ger "Sie dürfen diesen Befehl nicht in einer Transaktion ausführen"
+ geo "ტრანზაქციაში ამ ბრძანების შესრულების უფლება არ გაქვთ"
hun "Az On szamara nem engedelyezett a parancs vegrehajtasa a tranzakcioban"
ita "Non puoi eseguire questo comando in una transazione"
jpn "このコマンドはトランザクション内で実行できません。"
@@ -4190,6 +4368,7 @@ ER_ERROR_DURING_COMMIT
est "Viga %M käsu COMMIT täitmisel"
fre "Erreur %M lors du COMMIT"
ger "Fehler %M beim COMMIT"
+ geo "შეცდომა %M COMMIT-ის დროს"
hindi "COMMIT के दौरान %M त्रुटि हुई"
hun "%M hiba a COMMIT vegrehajtasa soran"
ita "Rilevato l'errore %M durante il COMMIT"
@@ -4209,6 +4388,7 @@ ER_ERROR_DURING_ROLLBACK
est "Viga %M käsu ROLLBACK täitmisel"
fre "Erreur %M lors du ROLLBACK"
ger "Fehler %M beim ROLLBACK"
+ geo "შეცდომა %M ROLLBACK-ის დროს"
hindi "ROLLBACK के दौरान %M त्रुटि हुई"
hun "%M hiba a ROLLBACK vegrehajtasa soran"
ita "Rilevato l'errore %M durante il ROLLBACK"
@@ -4228,6 +4408,7 @@ ER_ERROR_DURING_FLUSH_LOGS
est "Viga %M käsu FLUSH_LOGS täitmisel"
fre "Erreur %M lors du FLUSH_LOGS"
ger "Fehler %M bei FLUSH_LOGS"
+ geo "შეცდომა %M FLUSH LOGS-ის დროს"
hindi "FLUSH_LOGS के दौरान %M त्रुटि हुई"
hun "%M hiba a FLUSH_LOGS vegrehajtasa soran"
ita "Rilevato l'errore %M durante il FLUSH_LOGS"
@@ -4247,6 +4428,7 @@ ER_ERROR_DURING_CHECKPOINT
est "Viga %M käsu CHECKPOINT täitmisel"
fre "Erreur %M lors du CHECKPOINT"
ger "Fehler %M bei CHECKPOINT"
+ geo "შეცდომა %M CHECKPOINT-ის დროს"
hindi "CHECKPOINT के दौरान %M त्रुटि हुई"
hun "%M hiba a CHECKPOINT vegrehajtasa soran"
ita "Rilevato l'errore %M durante il CHECKPOINT"
@@ -4266,6 +4448,7 @@ ER_NEW_ABORTING_CONNECTION 08S01
est "Ühendus katkestatud %lld andmebaas: '%-.192s' kasutaja: '%-.48s' masin: '%-.64s' (%-.64s)"
fre "Connection %lld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' hôte: '%-.64s' (%-.64s)"
ger "Abbruch der Verbindung %lld zur Datenbank '%-.192s'. Benutzer: '%-.48s', Host: '%-.64s' (%-.64s)"
+ geo "შეწყდა კავშირი %lld ბაზამდე: '%-.192s' მომხმარებელი: '%-.48s' ჰოსტი: '%-.64s' (%-.64s)"
ita "Interrotta la connessione %lld al db: ''%-.192s' utente: '%-.48s' host: '%-.64s' (%-.64s)"
jpn "接続 %lld が中断されました。データベース: '%-.192s' ユーザー: '%-.48s' ホスト: '%-.64s' (%-.64s)"
nla "Afgebroken verbinding %lld naar db: '%-.192s' gebruiker: '%-.48s' host: '%-.64s' (%-.64s)"
@@ -4278,11 +4461,13 @@ ER_NEW_ABORTING_CONNECTION 08S01
ER_UNUSED_10
chi "你应当永远看不到这个"
eng "You should never see it"
+ geo "ეს ვერასდროს უნდა დაინახოთ"
spa "Nunca lo debería vd de ver"
ER_FLUSH_MASTER_BINLOG_CLOSED
chi "Binlog 已关闭, 不能 RESET MASTER"
eng "Binlog closed, cannot RESET MASTER"
ger "Binlog geschlossen. Kann RESET MASTER nicht ausführen"
+ geo "Binlog-ი დახურულია. RESET MASTER-ის გაშვება შეუძლებელია"
jpn "バイナリログがクローズされています。RESET MASTER を実行できません。"
por "Binlog fechado. Não pode fazer RESET MASTER"
rus "Двоичный журнал обновления закрыт, невозможно выполнить RESET MASTER"
@@ -4296,6 +4481,7 @@ ER_INDEX_REBUILD
eng "Failed rebuilding the index of dumped table '%-.192s'"
fre "La reconstruction de l'index de la table copiée '%-.192s' a échoué"
ger "Neuerstellung des Index der Dump-Tabelle '%-.192s' fehlgeschlagen"
+ geo "შეცდომა შენახული ცხრილის ('%-.192s') ინდექსის თავიდან აგებისას"
greek "Failed rebuilding the index of dumped table '%-.192s'"
hun "Failed rebuilding the index of dumped table '%-.192s'"
ita "Fallita la ricostruzione dell'indice della tabella copiata '%-.192s'"
@@ -4313,6 +4499,7 @@ ER_MASTER
eng "Error from master: '%-.64s'"
fre "Erreur reçue du maître: '%-.64s'"
ger "Fehler vom Master: '%-.64s'"
+ geo "შეცდომა მთავარი სერვერიდან: '%-.64s'"
ita "Errore dal master: '%-.64s"
jpn "マスターでエラーが発生: '%-.64s'"
nla "Fout van master: '%-.64s'"
@@ -4329,6 +4516,7 @@ ER_MASTER_NET_READ 08S01
eng "Net error reading from master"
fre "Erreur de lecture réseau reçue du maître"
ger "Netzfehler beim Lesen vom Master"
+ geo "ქსელის შეცდომა მთავარი სერვერიდან წაკითხვისას"
ita "Errore di rete durante la ricezione dal master"
jpn "マスターからのデータ受信中のネットワークエラー"
nla "Net fout tijdens lezen van master"
@@ -4345,6 +4533,7 @@ ER_MASTER_NET_WRITE 08S01
eng "Net error writing to master"
fre "Erreur d'écriture réseau reçue du maître"
ger "Netzfehler beim Schreiben zum Master"
+ geo "ქსელის შეცდომა მთავარ სერვერზე ჩაწერისას"
ita "Errore di rete durante l'invio al master"
jpn "マスターへのデータ送信中のネットワークエラー"
nla "Net fout tijdens schrijven naar master"
@@ -4362,6 +4551,7 @@ ER_FT_MATCHING_KEY_NOT_FOUND
est "Ei suutnud leida FULLTEXT indeksit, mis kattuks kasutatud tulpadega"
fre "Impossible de trouver un index FULLTEXT correspondant à cette liste de colonnes"
ger "Kann keinen FULLTEXT-Index finden, der der Feldliste entspricht"
+ geo "სვეტების სიის შესაბამისი FULLTEXT ინდექსი ვერ ვიპოვე"
ita "Impossibile trovare un indice FULLTEXT che corrisponda all'elenco delle colonne"
jpn "列リストに対応する全文索引(FULLTEXT)が見つかりません。"
nla "Kan geen FULLTEXT index vinden passend bij de kolom lijst"
@@ -4379,6 +4569,7 @@ ER_LOCK_OR_ACTIVE_TRANSACTION
est "Ei suuda täita antud käsku kuna on aktiivseid lukke või käimasolev transaktsioon"
fre "Impossible d'exécuter la commande car vous avez des tables verrouillées ou une transaction active"
ger "Kann den angegebenen Befehl wegen einer aktiven Tabellensperre oder einer aktiven Transaktion nicht ausführen"
+ geo "მითითებული ბრძანების გაშვება აქტიური დაბლოკილი ცხრილების ან აქტიური ტრანზაქციის არსებობის გამო შეუძლებელია"
ita "Impossibile eseguire il comando richiesto: tabelle sotto lock o transazione in atto"
jpn "すでにアクティブな表ロックやトランザクションがあるため、コマンドを実行できません。"
nla "Kan het gegeven commando niet uitvoeren, want u heeft actieve gelockte tabellen of een actieve transactie"
@@ -4396,6 +4587,7 @@ ER_UNKNOWN_SYSTEM_VARIABLE
est "Tundmatu süsteemne muutuja '%-.*s'"
fre "Variable système '%-.*s' inconnue"
ger "Unbekannte Systemvariable '%-.*s'"
+ geo "უცნობი სისტემური ცვლადი '%-.*s'"
hindi "अज्ञात सिस्टम वैरिएबल '%-.*s'"
ita "Variabile di sistema '%-.*s' sconosciuta"
jpn "'%-.*s' は不明なシステム変数です。"
@@ -4414,6 +4606,7 @@ ER_CRASHED_ON_USAGE
est "Tabel '%-.192s' on märgitud vigaseks ja tuleb parandada"
fre "La table '%-.192s' est marquée 'crashed' et devrait être réparée"
ger "Tabelle '%-.192s' ist als defekt markiert und sollte repariert werden"
+ geo "ცხრილი '%-.192s' მონიშნულია, როგორც ავარიული და შეკეთებას საჭიროებს"
ita "La tabella '%-.192s' e` segnalata come corrotta e deve essere riparata"
jpn "表 '%-.192s' は壊れています。修復が必要です。"
nla "Tabel '%-.192s' staat als gecrashed gemarkeerd en dient te worden gerepareerd"
@@ -4431,6 +4624,7 @@ ER_CRASHED_ON_REPAIR
est "Tabel '%-.192s' on märgitud vigaseks ja viimane (automaatne?) parandus ebaõnnestus"
fre "La table '%-.192s' est marquée 'crashed' et le dernier 'repair' a échoué"
ger "Tabelle '%-.192s' ist als defekt markiert und der letzte (automatische?) Reparaturversuch schlug fehl"
+ geo "ცხრილი '%-.192s' მონიშნულია, როგორც ავარიული და ბოლო (ავტომატური?) შეკეთება წარუმატებლად დასრულდა"
ita "La tabella '%-.192s' e` segnalata come corrotta e l'ultima ricostruzione (automatica?) e` fallita"
jpn "表 '%-.192s' は壊れています。修復(自動?)にも失敗しています。"
nla "Tabel '%-.192s' staat als gecrashed gemarkeerd en de laatste (automatische?) reparatie poging mislukte"
@@ -4447,6 +4641,7 @@ ER_WARNING_NOT_COMPLETE_ROLLBACK
est "Hoiatus: mõnesid transaktsioone mittetoetavaid tabeleid ei suudetud tagasi kerida"
fre "Attention: certaines tables ne supportant pas les transactions ont été changées et elles ne pourront pas être restituées"
ger "Änderungen an einigen nicht transaktionalen Tabellen konnten nicht zurückgerollt werden"
+ geo "გაფრთხილება: ზოგიერთი არატრანზაქციულად შეცვლილი ცხრილების დაბრუნება შეუძლებელია"
ita "Attenzione: Alcune delle modifiche alle tabelle non transazionali non possono essere ripristinate (roll back impossibile)"
jpn "トランザクション対応ではない表への変更はロールバックされません。"
nla "Waarschuwing: Roll back mislukt voor sommige buiten transacties gewijzigde tabellen"
@@ -4463,6 +4658,7 @@ ER_TRANS_CACHE_FULL
est "Mitme lausendiga transaktsioon nõudis rohkem ruumi kui lubatud 'max_binlog_cache_size' muutujaga. Suurenda muutuja väärtust ja proovi uuesti"
fre "Cette transaction à commandes multiples nécessite plus de 'max_binlog_cache_size' octets de stockage, augmentez cette variable de mariadbd et réessayez"
ger "Transaktionen, die aus mehreren Befehlen bestehen, benötigten mehr als 'max_binlog_cache_size' Bytes an Speicher. Btte vergrössern Sie diese Server-Variable versuchen Sie es noch einmal"
+ geo "ტრანზაქციებს, რომლებიც ბევრ ბრძანებას შეიცავენ, max_binlog_cache_size ბაიტზე მეტი დასჭირდა. გაზარდეთ ცვლადის მნიშვნელობა ან თავიდან სცადეთ"
ita "La transazione a comandi multipli (multi-statement) ha richiesto piu` di 'max_binlog_cache_size' bytes di disco: aumentare questa variabile di mariadbd e riprovare"
jpn "複数ステートメントから成るトランザクションが 'max_binlog_cache_size' 以上の容量を必要としました。このシステム変数を増加して、再試行してください。"
nla "Multi-statement transactie vereist meer dan 'max_binlog_cache_size' bytes opslag. Verhoog deze mariadbd variabele en probeer opnieuw"
@@ -4477,6 +4673,7 @@ ER_SLAVE_MUST_STOP
eng "This operation cannot be performed as you have a running slave '%2$*1$s'; run STOP SLAVE '%2$*1$s' first"
fre "Cette opération ne peut être réalisée avec un esclave '%2$*1$s' actif, faites STOP SLAVE '%2$*1$s' d'abord"
ger "Diese Operation kann bei einem aktiven Slave '%2$*1$s' nicht durchgeführt werden. Bitte zuerst STOP SLAVE '%2$*1$s' ausführen"
+ geo "დამორჩილებულ სერვერზე ('%2$*1$s') ამ ოპერაციის განხორციელება შეუძლებელია. ჯერ გაუშვით STOP SLAVE '%2$*1$s'"
ita "Questa operazione non puo' essere eseguita con un database 'slave' '%2$*1$s' che gira, lanciare prima STOP SLAVE '%2$*1$s'"
nla "Deze operatie kan niet worden uitgevoerd met een actieve slave '%2$*1$s', doe eerst STOP SLAVE '%2$*1$s'"
por "Esta operação não pode ser realizada com um 'slave' '%2$*1$s' em execução. Execute STOP SLAVE '%2$*1$s' primeiro"
@@ -4491,6 +4688,7 @@ ER_SLAVE_NOT_RUNNING
eng "This operation requires a running slave; configure slave and do START SLAVE"
fre "Cette opération nécessite un esclave actif, configurez les esclaves et faites START SLAVE"
ger "Diese Operation benötigt einen aktiven Slave. Bitte Slave konfigurieren und mittels START SLAVE aktivieren"
+ geo "ამ ოპერაციას გაშვებული დამორჩილებული სერვერი ესაჭიროება. ჯერ გაუშვით START SLAVE"
ita "Questa operaione richiede un database 'slave', configurarlo ed eseguire START SLAVE"
jpn "この処理は、稼働中のスレーブでなければ実行できません。スレーブの設定をしてSTART SLAVEコマンドを実行してください。"
nla "Deze operatie vereist een actieve slave, configureer slave en doe dan START SLAVE"
@@ -4506,6 +4704,7 @@ ER_BAD_SLAVE
eng "The server is not configured as slave; fix in config file or with CHANGE MASTER TO"
fre "Le server n'est pas configuré comme un esclave, changez le fichier de configuration ou utilisez CHANGE MASTER TO"
ger "Der Server ist nicht als Slave konfiguriert. Bitte in der Konfigurationsdatei oder mittels CHANGE MASTER TO beheben"
+ geo "სერვერი დამორჩილებული როლისთვის მორგებული არაა. ჩაასწორეთ კონფიგურაციის ფაილი ან გაუშვით ბრძანება CHANGE MASTER TO"
ita "Il server non e' configurato come 'slave', correggere il file di configurazione cambiando CHANGE MASTER TO"
jpn "このサーバーはスレーブとして設定されていません。コンフィグファイルかCHANGE MASTER TOコマンドで設定して下さい。"
nla "De server is niet geconfigureerd als slave, fix in configuratie bestand of met CHANGE MASTER TO"
@@ -4520,6 +4719,7 @@ ER_MASTER_INFO
eng "Could not initialize master info structure for '%.*s'; more error messages can be found in the MariaDB error log"
fre "Impossible d'initialiser les structures d'information de maître '%.*s', vous trouverez des messages d'erreur supplémentaires dans le journal des erreurs de MariaDB"
ger "Konnte Master-Info-Struktur '%.*s' nicht initialisieren. Weitere Fehlermeldungen können im MariaDB-Error-Log eingesehen werden"
+ geo "'%.*s'-სთვის მთავარი სერვერის ინფორმაციის სტრუქტურის ინიციალიზაცია სეუძლებელია. მეტი ინფორმაციისთვის MariaDB-ის შეცდომების ჟურნალი იხილეთ"
jpn "'master info '%.*s''構造体の初期化ができませんでした。MariaDBエラーログでエラーメッセージを確認してください。"
serbian "Nisam mogao da inicijalizujem informacionu strukturu glavnog servera, proverite da li imam privilegije potrebne za pristup file-u 'master.info' '%.*s'"
spa "No pude inicializar estructura info de maestro (master) para '%.*s'; se pueden ver más mensajes de error en el historial (log) de errores de MariaDB"
@@ -4531,6 +4731,7 @@ ER_SLAVE_THREAD
eng "Could not create slave thread; check system resources"
fre "Impossible de créer une tâche esclave, vérifiez les ressources système"
ger "Konnte Slave-Thread nicht starten. Bitte System-Ressourcen überprüfen"
+ geo "დამორჩილებული სერვერის ნაკადის შექმნის შეცდომა. გადაამოწმეთ სისტემური რესურსები"
ita "Impossibile creare il thread 'slave', controllare le risorse di sistema"
jpn "スレーブスレッドを作成できません。システムリソースを確認してください。"
nla "Kon slave thread niet aanmaken, controleer systeem resources"
@@ -4547,6 +4748,7 @@ ER_TOO_MANY_USER_CONNECTIONS 42000
est "Kasutajal %-.64s on juba rohkem ühendusi kui lubatud 'max_user_connections' muutujaga"
fre "L'utilisateur %-.64s possède déjà plus de 'max_user_connections' connexions actives"
ger "Benutzer '%-.64s' hat mehr als 'max_user_connections' aktive Verbindungen"
+ geo "მომხმარებელს %-.64s უკვე 'max_user_connections'-ზე მეტი აქტიური კავშირი გააჩნია"
hindi "यूज़र %-.64s के पहले से ही 'max_user_connections' से अधिक सक्रिय कनेक्शन्स हैं"
ita "L'utente %-.64s ha gia' piu' di 'max_user_connections' connessioni attive"
jpn "ユーザー '%-.64s' はすでに 'max_user_connections' 以上のアクティブな接続を行っています。"
@@ -4564,6 +4766,7 @@ ER_SET_CONSTANTS_ONLY
est "Ainult konstantsed suurused on lubatud SET klauslis"
fre "Seules les expressions constantes sont autorisées avec SET"
ger "Bei diesem Befehl dürfen nur konstante Ausdrücke verwendet werden"
+ geo "ამ ბრძანებასთან ერთად მხოლოდ კონსტანტური გამოსახულებების გამოყენება შეგიძლიათ"
hindi "इस स्टेटमेंट में आप केवल CONSTANT EXPRESSIONS का उपयोग कर सकते हैं"
ita "Si possono usare solo espressioni costanti con SET"
jpn "SET処理が失敗しました。"
@@ -4581,6 +4784,7 @@ ER_LOCK_WAIT_TIMEOUT
est "Kontrollaeg ületatud luku järel ootamisel; Proovi transaktsiooni otsast alata"
fre "Timeout sur l'obtention du verrou"
ger "Beim Warten auf eine Sperre wurde die zulässige Wartezeit überschritten. Bitte versuchen Sie, die Transaktion neu zu starten"
+ geo "ბლოკის მოლოდინის ვადა ამოიწურა. სცადეთ, ტრანზაქცია თავიდან გაუშვათ"
ita "E' scaduto il timeout per l'attesa del lock"
jpn "ロック待ちがタイムアウトしました。トランザクションを再試行してください。"
nla "Lock wacht tijd overschreden"
@@ -4597,6 +4801,7 @@ ER_LOCK_TABLE_FULL
est "Lukkude koguarv ületab lukutabeli suuruse"
fre "Le nombre total de verrou dépasse la taille de la table des verrous"
ger "Die Gesamtzahl der Sperren überschreitet die Größe der Sperrtabelle"
+ geo "ბლოკების ჯამური რიცხვი ბლოკების ცხრილის ზომას აჭარბებს"
hindi "लॉक्स की कुल संख्या लॉक टेबल के साइज से अधिक है"
ita "Il numero totale di lock e' maggiore della grandezza della tabella di lock"
jpn "ロックの数が多すぎます。"
@@ -4614,6 +4819,7 @@ ER_READ_ONLY_TRANSACTION 25000
est "Uuenduslukke ei saa kasutada READ UNCOMMITTED transaktsiooni käigus"
fre "Un verrou en update ne peut être acquit pendant une transaction READ UNCOMMITTED"
ger "Während einer READ-UNCOMMITTED-Transaktion können keine UPDATE-Sperren angefordert werden"
+ geo "განახლების დაბლოკვების მიღება შეუძლებელია READ UNCOMMITTED ტრანზაქციის დროს"
ita "I lock di aggiornamento non possono essere acquisiti durante una transazione 'READ UNCOMMITTED'"
jpn "読み込み専用トランザクションです。"
nla "Update locks kunnen niet worden verkregen tijdens een READ UNCOMMITTED transactie"
@@ -4630,6 +4836,7 @@ ER_DROP_DB_WITH_READ_LOCK
est "DROP DATABASE ei ole lubatud kui lõim omab globaalset READ lukku"
fre "DROP DATABASE n'est pas autorisée pendant qu'une tâche possède un verrou global en lecture"
ger "DROP DATABASE ist nicht erlaubt, solange der Thread eine globale Lesesperre hält"
+ geo "DROP DATABASE დაუშვებელია, სანამ ნაკადი კითხვის გლობალური ბლოკს შეიცავს"
ita "DROP DATABASE non e' permesso mentre il thread ha un lock globale di lettura"
jpn "グローバルリードロックを保持している間は、DROP DATABASE を実行できません。"
nla "DROP DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit"
@@ -4646,6 +4853,7 @@ ER_CREATE_DB_WITH_READ_LOCK
est "CREATE DATABASE ei ole lubatud kui lõim omab globaalset READ lukku"
fre "CREATE DATABASE n'est pas autorisée pendant qu'une tâche possède un verrou global en lecture"
ger "CREATE DATABASE ist nicht erlaubt, solange der Thread eine globale Lesesperre hält"
+ geo "CREATE DATABASE დაუშვებელია, სანამ ნაკადი კითხვის გლობალურ ბლოკს შეიცავს"
ita "CREATE DATABASE non e' permesso mentre il thread ha un lock globale di lettura"
jpn "グローバルリードロックを保持している間は、CREATE DATABASE を実行できません。"
nla "CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit"
@@ -4661,6 +4869,7 @@ ER_WRONG_ARGUMENTS
est "Vigased parameetrid %s-le"
fre "Mauvais arguments à %s"
ger "Falsche Argumente für %s"
+ geo "%s-ის არგუმენტები არასწორია"
hindi "%s को गलत आर्ग्यूमेंट्स"
ita "Argomenti errati a %s"
jpn "%s の引数が不正です"
@@ -4677,6 +4886,7 @@ ER_NO_PERMISSION_TO_CREATE_USER 42000
est "Kasutajal '%s'@'%s' ei ole lubatud luua uusi kasutajaid"
fre "'%s'@'%s' n'est pas autorisé à créer de nouveaux utilisateurs"
ger "'%s'@'%s' ist nicht berechtigt, neue Benutzer hinzuzufügen"
+ geo "'%s'@'%s'-ს ახალი მომხმარებლების შექმნის უფლება არ აქვს"
hindi "'%s'@'%s' को नए यूज़र्स बनाने की अनुमति नहीं है"
ita "A '%s'@'%s' non e' permesso creare nuovi utenti"
nla "'%s'@'%s' mag geen nieuwe gebruikers creeren"
@@ -4692,6 +4902,7 @@ ER_UNION_TABLES_IN_DIFFERENT_DIR
est "Vigane tabelimääratlus; kõik MERGE tabeli liikmed peavad asuma samas andmebaasis"
fre "Définition de table incorrecte; toutes les tables MERGE doivent être dans la même base de donnée"
ger "Falsche Tabellendefinition. Alle MERGE-Tabellen müssen sich in derselben Datenbank befinden"
+ geo "ცხრილის არასწორი აღწერა. ყველა MERGE ცხრილი ერთი და იგივე მონაცემთა ბაზაში უნდა იყოს"
ita "Definizione della tabella errata; tutte le tabelle di tipo MERGE devono essere nello stesso database"
jpn "不正な表定義です。MERGE表の構成表はすべて同じデータベース内になければなりません。"
nla "Incorrecte tabel definitie; alle MERGE tabellen moeten tot dezelfde database behoren"
@@ -4707,6 +4918,7 @@ ER_LOCK_DEADLOCK 40001
est "Lukustamisel tekkis tupik (deadlock); alusta transaktsiooni otsast"
fre "Deadlock découvert en essayant d'obtenir les verrous : essayez de redémarrer la transaction"
ger "Beim Versuch, eine Sperre anzufordern, ist ein Deadlock aufgetreten. Versuchen Sie, die Transaktion neu zu starten"
+ geo "ჩიხი ბლოკის მიღების მცდელობისას. სცადეთ, ტრანზაქცია თავიდან გაუშვათ"
ita "Trovato deadlock durante il lock; Provare a far ripartire la transazione"
jpn "ロック取得中にデッドロックが検出されました。トランザクションを再試行してください。"
nla "Deadlock gevonden tijdens lock-aanvraag poging; Probeer herstart van de transactie"
@@ -4722,6 +4934,7 @@ ER_TABLE_CANT_HANDLE_FT
est "Antud tabelitüüp (%s) ei toeta FULLTEXT indekseid"
fre "Le type de table utilisé (%s) ne supporte pas les index FULLTEXT"
ger "Der verwendete Tabellentyp (%s) unterstützt keine FULLTEXT-Indizes"
+ geo "საცავის ძრავს (%s) FULLTEXT ინდექსების მხარდაჭერა არ გააჩნია"
hindi "स्टोरेज इंजन '%s' FULLTEXT इन्डेक्सेस को सपोर्ट नहीं करता"
ita "La tabella usata (%s) non supporta gli indici FULLTEXT"
nla "Het gebruikte tabel type (%s) ondersteund geen FULLTEXT indexen"
@@ -4736,6 +4949,7 @@ ER_CANNOT_ADD_FOREIGN
eng "Cannot add foreign key constraint for `%s`"
fre "Impossible d'ajouter des contraintes d'index externe à `%s`"
ger "Fremdschlüssel-Beschränkung kann nicht hinzugefügt werden für `%s`"
+ geo "'%s'-სთვის გარე გასაღების შეზღუდვის დამატება შეუძლებელია"
ita "Impossibile aggiungere il vincolo di integrita' referenziale (foreign key constraint) a `%s`"
jpn "`%s` 外部キー制約を追加できません。"
nla "Kan foreign key beperking niet toevoegen vor `%s`"
@@ -4750,6 +4964,7 @@ ER_NO_REFERENCED_ROW 23000
eng "Cannot add or update a child row: a foreign key constraint fails"
fre "Impossible d'ajouter un enregistrement fils : une constrainte externe l'empèche"
ger "Hinzufügen oder Aktualisieren eines Kind-Datensatzes schlug aufgrund einer Fremdschlüssel-Beschränkung fehl"
+ geo "შვილი მწკრივის დამატება ან განახლება შეუძლებელია. გარე გასაღების შეზღუდვა არ მოწმდება"
greek "Cannot add a child row: a foreign key constraint fails"
hun "Cannot add a child row: a foreign key constraint fails"
ita "Impossibile aggiungere la riga: un vincolo d'integrita' referenziale non e' soddisfatto"
@@ -4766,6 +4981,7 @@ ER_ROW_IS_REFERENCED 23000
eng "Cannot delete or update a parent row: a foreign key constraint fails"
fre "Impossible de supprimer un enregistrement père : une constrainte externe l'empèche"
ger "Löschen oder Aktualisieren eines Eltern-Datensatzes schlug aufgrund einer Fremdschlüssel-Beschränkung fehl"
+ geo "მშობელი მწკრივის წაშლა ან განახლება შეუძლებელია. გარე გასაღების შეზღუდვა არ მოწმდება"
greek "Cannot delete a parent row: a foreign key constraint fails"
hun "Cannot delete a parent row: a foreign key constraint fails"
ita "Impossibile cancellare la riga: un vincolo d'integrita' referenziale non e' soddisfatto"
@@ -4779,6 +4995,7 @@ ER_CONNECT_TO_MASTER 08S01
chi "连接master时出错:%-.128s"
eng "Error connecting to master: %-.128s"
ger "Fehler bei der Verbindung zum Master: %-.128s"
+ geo "მთავარ სერვერთან მიერთების შეცდომა: %-.128s"
ita "Errore durante la connessione al master: %-.128s"
jpn "マスターへの接続エラー: %-.128s"
nla "Fout bij opbouwen verbinding naar master: %-.128s"
@@ -4790,6 +5007,7 @@ ER_QUERY_ON_MASTER
chi "在Master上运行查询时出错:%-.128s"
eng "Error running query on master: %-.128s"
ger "Beim Ausführen einer Abfrage auf dem Master trat ein Fehler auf: %-.128s"
+ geo "მთავარ სერვერზე მოთხოვნის გაშვების შეცდომა: %-.128s"
ita "Errore eseguendo una query sul master: %-.128s"
jpn "マスターでのクエリ実行エラー: %-.128s"
nla "Fout bij uitvoeren query op master: %-.128s"
@@ -4802,6 +5020,7 @@ ER_ERROR_WHEN_EXECUTING_COMMAND
eng "Error when executing command %s: %-.128s"
est "Viga käsu %s täitmisel: %-.128s"
ger "Fehler beim Ausführen des Befehls %s: %-.128s"
+ geo "შეცდომა ბრძანების (%s) შესრულებისას: %-.128s"
ita "Errore durante l'esecuzione del comando %s: %-.128s"
jpn "%s コマンドの実行エラー: %-.128s"
nla "Fout tijdens uitvoeren van commando %s: %-.128s"
@@ -4815,6 +5034,7 @@ ER_WRONG_USAGE
eng "Incorrect usage of %s and %s"
est "Vigane %s ja %s kasutus"
ger "Falsche Verwendung von %s und %s"
+ geo "%s-ის და %s-ის არასწორი გამოყენება"
ita "Uso errato di %s e %s"
jpn "%s の %s に関する不正な使用法です。"
nla "Foutief gebruik van %s en %s"
@@ -4829,6 +5049,7 @@ ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 21000
eng "The used SELECT statements have a different number of columns"
est "Tulpade arv kasutatud SELECT lausetes ei kattu"
ger "Die verwendeten SELECT-Befehle liefern unterschiedliche Anzahlen von Feldern zurück"
+ geo "SELECT-ის გამოყენებულ ოპერატორებს სხვადასხვა რაოდენობის სვეტები გააჩნიათ"
ita "La SELECT utilizzata ha un numero di colonne differente"
jpn "使用のSELECT文が返す列数が違います。"
nla "De gebruikte SELECT commando's hebben een verschillend aantal kolommen"
@@ -4842,6 +5063,7 @@ ER_CANT_UPDATE_WITH_READLOCK
eng "Can't execute the query because you have a conflicting read lock"
est "Ei suuda täita päringut konfliktse luku tõttu"
ger "Augrund eines READ-LOCK-Konflikts kann die Abfrage nicht ausgeführt werden"
+ geo "მოთხოვნის შესრულება შეუძლებელია, რადგან თქვენი წაკითხვის ბლოკები კონფლიქტურია"
ita "Impossibile eseguire la query perche' c'e' un conflitto con in lock di lettura"
jpn "競合するリードロックを保持しているので、クエリを実行できません。"
nla "Kan de query niet uitvoeren vanwege een conflicterende read lock"
@@ -4855,6 +5077,7 @@ ER_MIXING_NOT_ALLOWED
eng "Mixing of transactional and non-transactional tables is disabled"
est "Transaktsioone toetavate ning mittetoetavate tabelite kooskasutamine ei ole lubatud"
ger "Die gleichzeitige Verwendung von Tabellen mit und ohne Transaktionsunterstützung ist deaktiviert"
+ geo "ტრანზაქციური და არატრანზაქციური ცხრილების შერევა აკრძალულია"
ita "E' disabilitata la possibilita' di mischiare tabelle transazionali e non-transazionali"
jpn "トランザクション対応の表と非対応の表の同時使用は無効化されています。"
nla "Het combineren van transactionele en niet-transactionele tabellen is uitgeschakeld"
@@ -4868,6 +5091,7 @@ ER_DUP_ARGUMENT
eng "Option '%s' used twice in statement"
est "Määrangut '%s' on lauses kasutatud topelt"
ger "Option '%s' wird im Befehl zweimal verwendet"
+ geo "გამოსახულებაში პარამეტრი '%s' ორჯერ გამოიყენება"
ita "L'opzione '%s' e' stata usata due volte nel comando"
jpn "オプション '%s' が2度使用されています。"
nla "Optie '%s' tweemaal gebruikt in opdracht"
@@ -4879,6 +5103,7 @@ ER_USER_LIMIT_REACHED 42000
chi "用户'%-.64s'已超过'%s'资源(当前值:%ld)"
eng "User '%-.64s' has exceeded the '%s' resource (current value: %ld)"
ger "Benutzer '%-.64s' hat die Ressourcenbeschränkung '%s' überschritten (aktueller Wert: %ld)"
+ geo "მომხმარებელი '%-.64s' აჭარბებს '%s' რესურსის გამოყენებას (მიმდინარე მნიშვნელობაა %ld)"
ita "L'utente '%-.64s' ha ecceduto la risorsa '%s' (valore corrente: %ld)"
jpn "ユーザー '%-.64s' はリソースの上限 '%s' に達しました。(現在値: %ld)"
nla "Gebruiker '%-.64s' heeft het maximale gebruik van de '%s' faciliteit overschreden (huidige waarde: %ld)"
@@ -4890,6 +5115,7 @@ ER_SPECIFIC_ACCESS_DENIED_ERROR 42000
chi "拒绝访问;您需要(至少一个)%-.128s特权用于此操作"
eng "Access denied; you need (at least one of) the %-.128s privilege(s) for this operation"
ger "Kein Zugriff. Hierfür wird die Berechtigung %-.128s benötigt"
+ geo "წვდომა აკრძალულია. ამ ოპერაციისთვის საჭიროა %-.128s პრივილეგია"
ita "Accesso non consentito. Serve il privilegio %-.128s per questa operazione"
jpn "アクセスは拒否されました。この操作には %-.128s 権限が(複数の場合はどれか1つ)必要です。"
nla "Toegang geweigerd. U moet het %-.128s privilege hebben voor deze operatie"
@@ -4902,6 +5128,7 @@ ER_LOCAL_VARIABLE
chi "变量'%-.64s'是一个SESSION变量,不能与Set Global一起使用"
eng "Variable '%-.64s' is a SESSION variable and can't be used with SET GLOBAL"
ger "Variable '%-.64s' ist eine lokale Variable und kann nicht mit SET GLOBAL verändert werden"
+ geo "ცვლადი %-.64s SESSION-ის ცვლადია და SET GLOBAL-ის საშუალებით ვერ შეიცვლება"
ita "La variabile '%-.64s' e' una variabile locale ( SESSION ) e non puo' essere cambiata usando SET GLOBAL"
jpn "変数 '%-.64s' はセッション変数です。SET GLOBALでは使用できません。"
nla "Variabele '%-.64s' is SESSION en kan niet worden gebruikt met SET GLOBAL"
@@ -4913,6 +5140,7 @@ ER_GLOBAL_VARIABLE
chi "变量'%-.64s'是全局变量,应该用SET GLOBAL设置"
eng "Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL"
ger "Variable '%-.64s' ist eine globale Variable und muss mit SET GLOBAL verändert werden"
+ geo "ცვლადი %-.64s გლობალური (GLOBAL) ცვლადია და SET GLOBAL-ით უნდა შეიცვალოს"
ita "La variabile '%-.64s' e' una variabile globale ( GLOBAL ) e deve essere cambiata usando SET GLOBAL"
jpn "変数 '%-.64s' はグローバル変数です。SET GLOBALを使用してください。"
nla "Variabele '%-.64s' is GLOBAL en dient te worden gewijzigd met SET GLOBAL"
@@ -4924,6 +5152,7 @@ ER_NO_DEFAULT 42000
chi "变量'%-.64s'没有默认值"
eng "Variable '%-.64s' doesn't have a default value"
ger "Variable '%-.64s' hat keinen Vorgabewert"
+ geo "ცვლადს %-.64s ნაგულისხმები მნიშვნელობა არ გააჩნია"
ita "La variabile '%-.64s' non ha un valore di default"
jpn "変数 '%-.64s' にはデフォルト値がありません。"
nla "Variabele '%-.64s' heeft geen standaard waarde"
@@ -4935,6 +5164,7 @@ ER_WRONG_VALUE_FOR_VAR 42000
chi "变量'%-.64s'无法设置为'%-.200T'的值"
eng "Variable '%-.64s' can't be set to the value of '%-.200T'"
ger "Variable '%-.64s' kann nicht auf '%-.200T' gesetzt werden"
+ geo "ცვლადს '%-.64s' მნიშვნელობას '%-.200T' ვერ მიანიჭებთ"
ita "Alla variabile '%-.64s' non puo' essere assegato il valore '%-.200T'"
jpn "変数 '%-.64s' に値 '%-.200T' を設定できません。"
nla "Variabele '%-.64s' kan niet worden gewijzigd naar de waarde '%-.200T'"
@@ -4946,6 +5176,7 @@ ER_WRONG_TYPE_FOR_VAR 42000
chi "变量'%-.64s'的参数类型不正确"
eng "Incorrect argument type to variable '%-.64s'"
ger "Falscher Argumenttyp für Variable '%-.64s'"
+ geo "არასწორი არგუმენტის ტიპი ცვლადისთვის '%-.64s'"
ita "Tipo di valore errato per la variabile '%-.64s'"
jpn "変数 '%-.64s' への値の型が不正です。"
nla "Foutief argumenttype voor variabele '%-.64s'"
@@ -4957,6 +5188,7 @@ ER_VAR_CANT_BE_READ
chi "变量'%-.64s'只能设置,不能读"
eng "Variable '%-.64s' can only be set, not read"
ger "Variable '%-.64s' kann nur verändert, nicht gelesen werden"
+ geo "ცვლადი '%-.64s' შეგიძლიათ მხოლოდ დააყენოთ, მისი წაკითხვა შეუძლებელია"
ita "Alla variabile '%-.64s' e' di sola scrittura quindi puo' essere solo assegnato un valore, non letto"
jpn "変数 '%-.64s' は書き込み専用です。読み込みはできません。"
nla "Variabele '%-.64s' kan alleen worden gewijzigd, niet gelezen"
@@ -4968,6 +5200,7 @@ ER_CANT_USE_OPTION_HERE 42000
chi "'%s'的使用/放置不正确"
eng "Incorrect usage/placement of '%s'"
ger "Falsche Verwendung oder Platzierung von '%s'"
+ geo "'%s' არასწორად გამოიყენება ან არასწორ ადგილასაა მითითებული"
ita "Uso/posizione di '%s' sbagliato"
jpn "'%s' の使用法または場所が不正です。"
nla "Foutieve toepassing/plaatsing van '%s'"
@@ -4979,6 +5212,7 @@ ER_NOT_SUPPORTED_YET 42000
chi "此版本的MariaDB尚未支持'%s'"
eng "This version of MariaDB doesn't yet support '%s'"
ger "Diese MariaDB-Version unterstützt '%s' nicht"
+ geo "MariaDB-ის ამ ვერსიას '%s'-ის მხარდაჭერა ჯერ არ გააჩნია"
ita "Questa versione di MariaDB non supporta ancora '%s'"
jpn "このバージョンのMariaDBでは、まだ '%s' を利用できません。"
nla "Deze versie van MariaDB ondersteunt nog geen '%s'"
@@ -4990,6 +5224,7 @@ ER_MASTER_FATAL_ERROR_READING_BINLOG
chi "从二进制日志读取数据时,从master遇到致命错误%d:'%-.320s'"
eng "Got fatal error %d from master when reading data from binary log: '%-.320s'"
ger "Schwerer Fehler %d: '%-.320s vom Master beim Lesen des binären Logs"
+ geo "ფატალური შეცდომა %d მთავარი სერვერიდან ბინარული ჟურნალიდან მონაცემების კითხვისას: '%-.320s'"
ita "Errore fatale %d: '%-.320s' dal master leggendo i dati dal log binario"
jpn "致命的なエラー %d: '%-.320s' がマスターでバイナリログ読み込み中に発生しました。"
nla "Kreeg fatale fout %d: '%-.320s' van master tijdens lezen van data uit binaire log"
@@ -5001,6 +5236,7 @@ ER_SLAVE_IGNORED_TABLE
chi "由于复制replicate-*-table规则,Slave SQL线程忽略了查询"
eng "Slave SQL thread ignored the query because of replicate-*-table rules"
ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert"
+ geo "დამორჩილებულმა SQL ნაკადმა replicate-*-table წესების გამო მოთხოვნა გამოტოვა"
jpn "replicate-*-table ルールに従って、スレーブSQLスレッドはクエリを無視しました。"
nla "Slave SQL thread negeerde de query vanwege replicate-*-table opties"
por "Slave SQL thread ignorado a consulta devido às normas de replicação-*-tabela"
@@ -5010,6 +5246,7 @@ ER_INCORRECT_GLOBAL_LOCAL_VAR
chi "变量'%-.192s'是一个%s变量"
eng "Variable '%-.192s' is a %s variable"
ger "Variable '%-.192s' ist eine %s-Variable"
+ geo "ცვლადი '%-.192s' %s ცვლადია"
jpn "変数 '%-.192s' は %s 変数です。"
nla "Variabele '%-.192s' is geen %s variabele"
serbian "Promenljiva '%-.192s' je %s promenljiva"
@@ -5019,6 +5256,7 @@ ER_WRONG_FK_DEF 42000
chi "'%-.192s'的外键定义不正确:%s"
eng "Incorrect foreign key definition for '%-.192s': %s"
ger "Falsche Fremdschlüssel-Definition für '%-.192s': %s"
+ geo "არასწორი გარე გასაღების აღწერა '%-.192s'-სთვის: %s"
jpn "外部キー '%-.192s' の定義の不正: %s"
nla "Incorrecte foreign key definitie voor '%-.192s': %s"
por "Definição errada da chave estrangeira para '%-.192s': %s"
@@ -5028,6 +5266,7 @@ ER_KEY_REF_DO_NOT_MATCH_TABLE_REF
chi "索引参考和表参考不匹配"
eng "Key reference and table reference don't match"
ger "Schlüssel- und Tabellenverweis passen nicht zusammen"
+ geo "გასაღების მიმართვა და ცხრილის მიმართვა ერთმანეთს არ ემთხვევა"
jpn "外部キーの参照表と定義が一致しません。"
nla "Sleutel- en tabelreferentie komen niet overeen"
por "Referência da chave e referência da tabela não coincidem"
@@ -5037,6 +5276,7 @@ ER_OPERAND_COLUMNS 21000
chi "操作数应包含%d列"
eng "Operand should contain %d column(s)"
ger "Operand sollte %d Spalte(n) enthalten"
+ geo "ოპერანდი %d სვეტს უნდა შეიცავდეს"
jpn "オペランドに %d 個の列が必要です。"
nla "Operand behoort %d kolommen te bevatten"
rus "Операнд должен содержать %d колонок"
@@ -5046,6 +5286,7 @@ ER_SUBQUERY_NO_1_ROW 21000
chi "子查询返回超过1行"
eng "Subquery returns more than 1 row"
ger "Unterabfrage lieferte mehr als einen Datensatz zurück"
+ geo "ქვემოთხოვნა ერთ ჩანაწერზე მეტს აბრუნებს"
jpn "サブクエリが2行以上の結果を返します。"
nla "Subquery retourneert meer dan 1 rij"
por "Subconsulta retorna mais que 1 registro"
@@ -5058,6 +5299,7 @@ ER_UNKNOWN_STMT_HANDLER
dan "Unknown prepared statement handler (%.*s) given to %s"
eng "Unknown prepared statement handler (%.*s) given to %s"
ger "Unbekannter Prepared-Statement-Handler (%.*s) für %s angegeben"
+ geo "უცნობი მომზადებული გამოსახულების დამმუშავებელი (%.*s) გადაცემულია %s-სთვის"
jpn "'%.*s' はプリペアードステートメントの不明なハンドルです。(%s で指定されました)"
nla "Onebekende prepared statement handler (%.*s) voor %s aangegeven"
por "Desconhecido manipulador de declaração preparado (%.*s) determinado para %s"
@@ -5068,6 +5310,7 @@ ER_CORRUPT_HELP_DB
chi "帮助数据库已损坏或不存在"
eng "Help database is corrupt or does not exist"
ger "Die Hilfe-Datenbank ist beschädigt oder existiert nicht"
+ geo "დახმარების ბაზა დაზიანებულია ან არ არსებობს"
jpn "ヘルプデータベースは壊れているか存在しません。"
nla "Help database is beschadigd of bestaat niet"
por "Banco de dado de ajuda corrupto ou não existente"
@@ -5077,6 +5320,7 @@ ER_CYCLIC_REFERENCE
chi "亚查询的死环参考"
eng "Cyclic reference on subqueries"
ger "Zyklischer Verweis in Unterabfragen"
+ geo "ციკლური მიმართვა ქვემოთხოვნაზე"
jpn "サブクエリの参照がループしています。"
nla "Cyclische verwijzing in subqueries"
por "Referência cíclica em subconsultas"
@@ -5088,6 +5332,7 @@ ER_AUTO_CONVERT
chi "将列'%s'从%s转换为%s"
eng "Converting column '%s' from %s to %s"
ger "Feld '%s' wird von %s nach %s umgewandelt"
+ geo "'%s' სვეტის გარდაქმნა '%s'-დან '%s'-მდე"
jpn "列 '%s' を %s から %s へ変換します。"
nla "Veld '%s' wordt van %s naar %s geconverteerd"
por "Convertendo coluna '%s' de %s para %s"
@@ -5099,6 +5344,7 @@ ER_ILLEGAL_REFERENCE 42S22
chi "参考'%-.64s'不支持(%s)"
eng "Reference '%-.64s' not supported (%s)"
ger "Verweis '%-.64s' wird nicht unterstützt (%s)"
+ geo "მიმართვა '%-.64s' მხარდაუჭერელია (%s)"
jpn "'%-.64s' の参照はできません。(%s)"
nla "Verwijzing '%-.64s' niet ondersteund (%s)"
por "Referência '%-.64s' não suportada (%s)"
@@ -5110,6 +5356,7 @@ ER_DERIVED_MUST_HAVE_ALIAS 42000
chi "每个派生的表必须有自己的别名"
eng "Every derived table must have its own alias"
ger "Für jede abgeleitete Tabelle muss ein eigener Alias angegeben werden"
+ geo "ყოველ მიღებულ ცხრილს საკუთარი ფსევდონიმი უნდა ჰქონდეს"
jpn "導出表には別名が必須です。"
nla "Voor elke afgeleide tabel moet een unieke alias worden gebruikt"
por "Cada tabela derivada deve ter seu próprio alias"
@@ -5119,6 +5366,7 @@ ER_SELECT_REDUCED 01000
chi "SELECT %u在优化期间被减"
eng "Select %u was reduced during optimization"
ger "Select %u wurde während der Optimierung reduziert"
+ geo "Select %u ოპტიმიზაციის პროცესში შემცირდა"
jpn "Select %u は最適化によって減らされました。"
nla "Select %u werd geredureerd tijdens optimtalisatie"
por "Select %u foi reduzido durante otimização"
@@ -5130,6 +5378,7 @@ ER_TABLENAME_NOT_ALLOWED_HERE 42000
chi "表'%-.192s'从其中一个SELECT中不能用于%-.32s"
eng "Table '%-.192s' from one of the SELECTs cannot be used in %-.32s"
ger "Tabelle '%-.192s', die in einem der SELECT-Befehle verwendet wurde, kann nicht in %-.32s verwendet werden"
+ geo "ცხრილი '%-.192s' ერთ-ერთი SELECT-დან არ შეიძლება %-.32s-ში გამოიყენოთ"
jpn "特定のSELECTのみで使用の表 '%-.192s' は %-.32s では使用できません。"
nla "Tabel '%-.192s' uit een van de SELECTS kan niet in %-.32s gebruikt worden"
por "Tabela '%-.192s' de um dos SELECTs não pode ser usada em %-.32s"
@@ -5139,6 +5388,7 @@ ER_NOT_SUPPORTED_AUTH_MODE 08004
chi "客户端不支持服务器请求的身份验证协议;考虑升级MariaDB客户端"
eng "Client does not support authentication protocol requested by server; consider upgrading MariaDB client"
ger "Client unterstützt das vom Server erwartete Authentifizierungsprotokoll nicht. Bitte aktualisieren Sie Ihren MariaDB-Client"
+ geo "კლიენტს სერვერის მიერ მოთხოვნილი ავთენტიკაციის პროტოკოლის მხარდაჭერა არ გააჩნია. სცადეთ, განაახლოთ MariaDB-ის კლიენტი"
jpn "クライアントはサーバーが要求する認証プロトコルに対応できません。MariaDBクライアントのアップグレードを検討してください。"
nla "Client ondersteunt het door de server verwachtte authenticatieprotocol niet. Overweeg een nieuwere MariaDB client te gebruiken"
por "Cliente não suporta o protocolo de autenticação exigido pelo servidor; considere a atualização do cliente MariaDB"
@@ -5148,6 +5398,7 @@ ER_SPATIAL_CANT_HAVE_NULL 42000
chi "SPATIAL索引的所有部分必须不为null"
eng "All parts of a SPATIAL index must be NOT NULL"
ger "Alle Teile eines SPATIAL-Index müssen als NOT NULL deklariert sein"
+ geo "SPATIAL ინდექსის ყველა ნაწილი NOT NULL უნდა იყოს"
jpn "空間索引のキー列は NOT NULL でなければいけません。"
nla "Alle delete van een SPATIAL index dienen als NOT NULL gedeclareerd te worden"
por "Todas as partes de uma SPATIAL index devem ser NOT NULL"
@@ -5157,6 +5408,7 @@ ER_COLLATION_CHARSET_MISMATCH 42000
chi "COLLATION'%s'无效地用于字符集'%s'"
eng "COLLATION '%s' is not valid for CHARACTER SET '%s'"
ger "COLLATION '%s' ist für CHARACTER SET '%s' ungültig"
+ geo "COLLATION '%s' არასწორია CHARACTER SET '%s'-სთვის"
jpn "COLLATION '%s' は CHARACTER SET '%s' に適用できません。"
nla "COLLATION '%s' is niet geldig voor CHARACTER SET '%s'"
por "COLLATION '%s' não é válida para CHARACTER SET '%s'"
@@ -5166,6 +5418,7 @@ ER_SLAVE_WAS_RUNNING
chi "Slave已经在运行"
eng "Slave is already running"
ger "Slave läuft bereits"
+ geo "დამორჩილებული ნაკადი უკვე გაშვებულია"
jpn "スレーブはすでに稼働中です。"
nla "Slave is reeds actief"
por "O slave já está rodando"
@@ -5175,6 +5428,7 @@ ER_SLAVE_WAS_NOT_RUNNING
chi "slave已经停止了"
eng "Slave already has been stopped"
ger "Slave wurde bereits angehalten"
+ geo "დამორჩილებული ნაკადი უკვე გაჩერებულია"
jpn "スレーブはすでに停止しています。"
nla "Slave is reeds gestopt"
por "O slave já está parado"
@@ -5184,6 +5438,7 @@ ER_TOO_BIG_FOR_UNCOMPRESS
chi "未压缩的数据量太大;最大量为%d(可能未压缩数据的长度已损坏)"
eng "Uncompressed data size too large; the maximum size is %d (probably, length of uncompressed data was corrupted)"
ger "Unkomprimierte Daten sind zu groß. Die maximale Größe beträgt %d (wahrscheinlich wurde die Länge der unkomprimierten Daten beschädigt)"
+ geo "შუკუმშავი მონაცემები ძალიან დიდია. მაქსიმალური ზომაა %d (ალბათ გაშლილი მონაცემების ზომა დაზიანებული იყო)"
jpn "展開後のデータが大きすぎます。最大サイズは %d です。(展開後データの長さ情報が壊れている可能性もあります。)"
nla "Ongecomprimeerder data is te groot; de maximum lengte is %d (waarschijnlijk, de lengte van de gecomprimeerde data was beschadigd)"
por "Tamanho muito grande dos dados des comprimidos. O máximo tamanho é %d. (provavelmente, o comprimento dos dados descomprimidos está corrupto)"
@@ -5192,6 +5447,7 @@ ER_ZLIB_Z_MEM_ERROR
chi "ZLIB:内存不足"
eng "ZLIB: Not enough memory"
ger "ZLIB: Nicht genug Speicher"
+ geo "ZLIP: არასაკმარისი მეხსიერება"
jpn "ZLIB: メモリ不足です。"
nla "ZLIB: Onvoldoende geheugen"
por "ZLIB: Não suficiente memória disponível"
@@ -5200,6 +5456,7 @@ ER_ZLIB_Z_BUF_ERROR
chi "ZLIB:输出缓冲区中没有足够的空间(可能未压缩数据的长度已损坏)"
eng "ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)"
ger "ZLIB: Im Ausgabepuffer ist nicht genug Platz vorhanden (wahrscheinlich wurde die Länge der unkomprimierten Daten beschädigt)"
+ geo "ZLIP: გამოტანის ბაფერში საკმარისი ადგილი არაა (ალბათ გაშლილი მონაცემების ზომა დაზიანებული იყო)"
jpn "ZLIB: 出力バッファに十分な空きがありません。(展開後データの長さ情報が壊れている可能性もあります。)"
nla "ZLIB: Onvoldoende ruimte in uitgaande buffer (waarschijnlijk, de lengte van de ongecomprimeerde data was beschadigd)"
por "ZLIB: Não suficiente espaço no buffer emissor (provavelmente, o comprimento dos dados descomprimidos está corrupto)"
@@ -5208,6 +5465,7 @@ ER_ZLIB_Z_DATA_ERROR
chi "ZLIB:输入数据已损坏"
eng "ZLIB: Input data corrupted"
ger "ZLIB: Eingabedaten beschädigt"
+ geo "ZLIB: შეყვანილი მონაცემების დაზიანებულია"
jpn "ZLIB: 入力データが壊れています。"
nla "ZLIB: Invoer data beschadigd"
por "ZLIB: Dados de entrada está corrupto"
@@ -5215,11 +5473,13 @@ ER_ZLIB_Z_DATA_ERROR
ER_CUT_VALUE_GROUP_CONCAT
chi "group_concat()削减了行%u. %s"
eng "Row %u was cut by %s)"
+ geo "მწკრივი %u გაჭრილია %s-ის მიერ)"
spa "La fila %u ha sido cortada por %s)"
ER_WARN_TOO_FEW_RECORDS 01000
chi "行%lu不包含所有列的数据"
eng "Row %lu doesn't contain data for all columns"
ger "Zeile %lu enthält nicht für alle Felder Daten"
+ geo "მწკრივი %lu ყველა სვეტისთვის მონაცემებს არ შეიცავს"
jpn "行 %lu はすべての列へのデータを含んでいません。"
nla "Rij %lu bevat niet de data voor alle kolommen"
por "Conta de registro é menor que a conta de coluna na linha %lu"
@@ -5228,6 +5488,7 @@ ER_WARN_TOO_MANY_RECORDS 01000
chi "行%lu被截断;它包含的数据比输入列更多"
eng "Row %lu was truncated; it contained more data than there were input columns"
ger "Zeile %lu gekürzt, die Zeile enthielt mehr Daten, als es Eingabefelder gibt"
+ geo "მწკრივი %lu წაკვეთილია. როცა შეყვანის სვეტები არსებობდა, ის მეტ მონაცემებს შეიცავდა"
jpn "行 %lu はデータを切り捨てられました。列よりも多いデータを含んでいました。"
nla "Regel %lu ingekort, bevatte meer data dan invoer kolommen"
por "Conta de registro é maior que a conta de coluna na linha %lu"
@@ -5236,17 +5497,20 @@ ER_WARN_NULL_TO_NOTNULL 22004
chi "列设置为默认值; NULL在行'%s'中提供给了NOT NULL列%lu"
eng "Column set to default value; NULL supplied to NOT NULL column '%s' at row %lu"
ger "Feld auf Vorgabewert gesetzt, da NULL für NOT-NULL-Feld '%s' in Zeile %lu angegeben"
+ geo "ველი ნაგულისხმებ მნიშვნელობას უდრის. მიწოდებულია NULL, როცა სვეტი %s' მწკრივში %lu მონიშნულია, როგორც NOT NULL"
jpn "列にデフォルト値が設定されました。NOT NULLの列 '%s' に 行 %lu で NULL が与えられました。"
por "Dado truncado, NULL fornecido para NOT NULL coluna '%s' na linha %lu"
spa "Columna puesta a valor por defecto; NULL suministrado para columna NOT NULL '%s' en la fila %lu"
ER_WARN_DATA_OUT_OF_RANGE 22003
chi "列'%s'行%lu的值超出范围"
eng "Out of range value for column '%s' at row %lu"
+ geo "სვეტის '%s' მწკრვში %lu მნიშვნელობა დიაპაზონს გარეთაა"
spa "Valor fuera de rango para la columna '%s' en la fila %lu"
WARN_DATA_TRUNCATED 01000
chi "数据被截断,在列'%s', 行%lu"
eng "Data truncated for column '%s' at row %lu"
ger "Daten abgeschnitten für Feld '%s' in Zeile %lu"
+ geo "სვეტისთვის '%s' მწკრივში '%lu მონაცემები წაკვეთილია"
jpn "列 '%s' の 行 %lu でデータが切り捨てられました。"
por "Dado truncado para coluna '%s' na linha %lu"
spa "Datos truncados para la columna '%s' en la fila %lu"
@@ -5254,6 +5518,7 @@ ER_WARN_USING_OTHER_HANDLER
chi "使用存储引擎%s 表格'%s'"
eng "Using storage engine %s for table '%s'"
ger "Speicher-Engine %s wird für Tabelle '%s' benutzt"
+ geo "გამოიყენება საცავის ძრავა %s ცხრილისთვის '%s'"
hindi "स्टोरेज इंजन %s का इस्तेमाल टेबल '%s' के लिए किया जा रहा है"
jpn "ストレージエンジン %s が表 '%s' に利用されています。"
por "Usando engine de armazenamento %s para tabela '%s'"
@@ -5263,6 +5528,7 @@ ER_CANT_AGGREGATE_2COLLATIONS
chi "非法混合collations(%s,%s)和(%s,%s),用于操作'%s'"
eng "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'"
ger "Unerlaubte Mischung von Sortierreihenfolgen (%s, %s) und (%s, %s) für Operation '%s'"
+ geo "დაუშვებელია კოლაციების (%s,%s) და (%s,%s) შერევა ოპერაციისთვის '%s'"
jpn "照合順序 (%s,%s) と (%s,%s) の混在は操作 '%s' では不正です。"
por "Combinação ilegal de collations (%s,%s) e (%s,%s) para operação '%s'"
spa "Mezcla ilegal de cotejos (collations) (%s,%s) y (%s,%s) para la operación '%s'"
@@ -5270,11 +5536,13 @@ ER_DROP_USER
chi "无法删除一个或多个请求的用户"
eng "Cannot drop one or more of the requested users"
ger "Kann einen oder mehrere der angegebenen Benutzer nicht löschen"
+ geo "ერთი ან მეტი მოთხოვნილი მომხმარებელის წაშლის შეცდომა"
spa "No puedo eliminar uno o más de los usuarios solicitados"
ER_REVOKE_GRANTS
chi "无法为一个或多个请求的用户撤消所有权限"
eng "Can't revoke all privileges for one or more of the requested users"
ger "Kann nicht alle Berechtigungen widerrufen, die für einen oder mehrere Benutzer gewährt wurden"
+ geo "ერთი ან მეტი მოთხოვნილი მომხმარებლისთვის პრივილეგიების ჩამორთმევის შეცდომა"
jpn "指定されたユーザーから指定された全ての権限を剥奪することができませんでした。"
por "Não pode revocar todos os privilégios, grant para um ou mais dos usuários pedidos"
spa "No puedo revocar todos los privilegios para uno o más de los usuarios solicitados"
@@ -5282,6 +5550,7 @@ ER_CANT_AGGREGATE_3COLLATIONS
chi "非法混合collations(%s,%s),(%s,%s)和(%s,%s),用于操作'%s'"
eng "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'"
ger "Unerlaubte Mischung von Sortierreihenfolgen (%s, %s), (%s, %s), (%s, %s) für Operation '%s'"
+ geo "კოლაციების (%s,%s), (%s,%s), (%s,%s) დაუშვებელი შერევა ოპერაციისთვის '%s'"
jpn "照合順序 (%s,%s), (%s,%s), (%s,%s) の混在は操作 '%s' では不正です。"
por "Ilegal combinação de collations (%s,%s), (%s,%s), (%s,%s) para operação '%s'"
spa "Mezcla ilegal de cotejos (collations) (%s,%s), (%s,%s), (%s,%s) para la operación '%s'"
@@ -5289,6 +5558,7 @@ ER_CANT_AGGREGATE_NCOLLATIONS
chi "非法混合collations操作'%s'"
eng "Illegal mix of collations for operation '%s'"
ger "Unerlaubte Mischung von Sortierreihenfolgen für Operation '%s'"
+ geo "კოლაციების დაუშვებელი შერევა ოპერაციისთვის '%s'"
jpn "操作 '%s' では不正な照合順序の混在です。"
por "Ilegal combinação de collations para operação '%s'"
spa "Mezcla ilegal de cotejos (collations) para la operación '%s'"
@@ -5296,6 +5566,7 @@ ER_VARIABLE_IS_NOT_STRUCT
chi "变量'%-.64s'不是可变组件(不能用作xxxx.variable_name)"
eng "Variable '%-.64s' is not a variable component (can't be used as XXXX.variable_name)"
ger "Variable '%-.64s' ist keine Variablen-Komponente (kann nicht als XXXX.variablen_name verwendet werden)"
+ geo "ცვლადი '%-.64s' ცვლადის კომპონენტი არაა (xxxx.variable_name სახით ვერ გამოიყენებთ)"
jpn "変数 '%-.64s' は構造変数の構成要素ではありません。(XXXX.変数名 という指定はできません。)"
por "Variável '%-.64s' não é uma variável componente (Não pode ser usada como XXXX.variável_nome)"
spa "La variable '%-.64s' no es un componente variable (No puede ser usada como XXXX.variable_name)"
@@ -5303,12 +5574,14 @@ ER_UNKNOWN_COLLATION
chi "未知的collation:'%-.64s'"
eng "Unknown collation: '%-.64s'"
ger "Unbekannte Sortierreihenfolge: '%-.64s'"
+ geo "უცნობი კოლაცია: '%-.64s'"
jpn "不明な照合順序: '%-.64s'"
por "Collation desconhecida: '%-.64s'"
spa "Cotejo (Collation) desconocido: '%-.64s'"
ER_SLAVE_IGNORED_SSL_PARAMS
chi "CHANGE MASTER中的SSL参数被忽略,因为此MariaDB从站未在没有SSL支持的情况下编译;如果启动了SSL的MariaDB从站,则可以使用它们"
eng "SSL parameters in CHANGE MASTER are ignored because this MariaDB slave was compiled without SSL support; they can be used later if MariaDB slave with SSL is started"
+ geo "ბრძანებაში 'CHANGE MASTER' SSL-ის პარამეტრები იგნორირებულია, რადგან დამორჩილებული 'MariaDB' SSL-ის მხარდაჭერის გარეშეა აგებული. ისინი მოგვიანებით შეგიძლიატ გამოიყენთ, თუ დამოკიდებულ MariaDB-ს SSL-ის მხარდაჭერა ექნება"
ger "SSL-Parameter in CHANGE MASTER werden ignoriert, weil dieser MariaDB-Slave ohne SSL-Unterstützung kompiliert wurde. Sie können aber später verwendet werden, wenn ein MariaDB-Slave mit SSL gestartet wird"
jpn "このMariaDBスレーブはSSLサポートを含めてコンパイルされていないので、CHANGE MASTER のSSLパラメータは無視されました。今後SSLサポートを持つMariaDBスレーブを起動する際に利用されます。"
por "SSL parâmetros em CHANGE MASTER são ignorados porque este escravo MariaDB foi compilado sem o SSL suporte. Os mesmos podem ser usados mais tarde quando o escravo MariaDB com SSL seja iniciado."
@@ -5317,6 +5590,7 @@ ER_SERVER_IS_IN_SECURE_AUTH_MODE
chi "服务器在--secure-auth模式下运行,但'%s'@'%s'具有旧格式的密码;请将密码更改为新格式"
eng "Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format"
ger "Server läuft im Modus --secure-auth, aber '%s'@'%s' hat ein Passwort im alten Format. Bitte Passwort ins neue Format ändern"
+ geo "სერვერი --secure-auth რეჟიმშია გაშვებული, მაგრამ '%s'@'%s'-ის პაროლი ძველ ფორმატშია. შეცვალეთ პაროლი ახალი ფორმატით"
jpn "サーバーは --secure-auth モードで稼働しています。しかし '%s'@'%s' は古い形式のパスワードを使用しています。新しい形式のパスワードに変更してください。"
por "Servidor está rodando em --secure-auth modo, porêm '%s'@'%s' tem senha no formato antigo; por favor troque a senha para o novo formato"
rus "Сервер запущен в режиме --secure-auth (безопасной авторизации), но для пользователя '%s'@'%s' пароль сохранён в старом формате; необходимо обновить формат пароля"
@@ -5325,6 +5599,7 @@ ER_WARN_FIELD_RESOLVED
chi "列或参考'%-.192s%s%-.192s%s%-.192s' 在SELECT #%d 中, 在SELECT #%d中得到解决"
eng "Field or reference '%-.192s%s%-.192s%s%-.192s' of SELECT #%d was resolved in SELECT #%d"
ger "Feld oder Verweis '%-.192s%s%-.192s%s%-.192s' im SELECT-Befehl Nr. %d wurde im SELECT-Befehl Nr. %d aufgelöst"
+ geo "ველი ან მიმართვა '%-.192s%s%-.192s%s%-.192s' SELECT-დან #%d ამოხსნილია SELECT-ში #%d"
jpn "フィールドまたは参照 '%-.192s%s%-.192s%s%-.192s' は SELECT #%d ではなく、SELECT #%d で解決されました。"
por "Campo ou referência '%-.192s%s%-.192s%s%-.192s' de SELECT #%d foi resolvido em SELECT #%d"
rus "Поле или ссылка '%-.192s%s%-.192s%s%-.192s' из SELECTа #%d была найдена в SELECTе #%d"
@@ -5334,6 +5609,7 @@ ER_BAD_SLAVE_UNTIL_COND
chi "START SLAVE UNTIL的参数或参数的组合不正确"
eng "Incorrect parameter or combination of parameters for START SLAVE UNTIL"
ger "Falscher Parameter oder falsche Kombination von Parametern für START SLAVE UNTIL"
+ geo "არასწორი პარამეტრი ან პარამეტრების კომბინაცია START SLAVE UNTIL-სთვის"
jpn "START SLAVE UNTIL へのパラメータまたはその組み合わせが不正です。"
por "Parâmetro ou combinação de parâmetros errado para START SLAVE UNTIL"
spa "Parámetro incorrecto o combinación de parámetros para START SLAVE UNTIL"
@@ -5341,6 +5617,7 @@ ER_MISSING_SKIP_SLAVE
chi "START SLAVE UNTIL进行逐步复制时建议使用--skip-slave-start;否则,如果有意外的Slave的mariadbd重启,可能有问题"
eng "It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mariadbd restart"
ger "Es wird empfohlen, mit --skip-slave-start zu starten, wenn mit START SLAVE UNTIL eine Schritt-für-Schritt-Replikation ausgeführt wird. Ansonsten gibt es Probleme, wenn ein Slave-Server unerwartet neu startet"
+ geo "START SLAVE UNTIL-ით ნაბიჯ-ნაბიჯ რეპლიკაციისთვის რეკომენდებულია გამოიყენოთ --skip-slave-start, რადგან დამორჩილებული mariadbd სერვერის გადატვირთვისას შეიძლებ პრობლემები შეგექმნათ"
jpn "START SLAVE UNTIL で段階的にレプリケーションを行う際には、--skip-slave-start オプションを使うことを推奨します。使わない場合、スレーブのmariadbdが不慮の再起動をすると問題が発生します。"
por "É recomendado para rodar com --skip-slave-start quando fazendo replicação passo-por-passo com START SLAVE UNTIL, de outra forma você não está seguro em caso de inesperada reinicialição do mariadbd escravo"
spa "Se recomienda usar --skip-slave-start al hacer réplica paso a paso con START SLAVE UNTIL; en caso contrario, obtendrá problemas si tiene lugar un rearranque inesperado del esclavo mariadb"
@@ -5348,6 +5625,7 @@ ER_UNTIL_COND_IGNORED
chi "不能启动SQL线程所以UNTIL选项被忽略"
eng "SQL thread is not to be started so UNTIL options are ignored"
ger "SQL-Thread soll nicht gestartet werden. Daher werden UNTIL-Optionen ignoriert"
+ geo "SQL ნაკადი არ გაშვებულა, ასე რომ UNTIL პარამეტრები იგნორირებულია"
jpn "スレーブSQLスレッドが開始されないため、UNTILオプションは無視されました。"
por "Thread SQL não pode ser inicializado tal que opções UNTIL são ignoradas"
spa "Un hilo (thread) SQL no ha de ser arrancado de esa manera HASTA que las opciones sean ignordas"
@@ -5355,6 +5633,7 @@ ER_WRONG_NAME_FOR_INDEX 42000
chi "索引名称'%-.100s'不正确"
eng "Incorrect index name '%-.100s'"
ger "Falscher Indexname '%-.100s'"
+ geo "ინდექსის სახელი ('%-.100s') არასწორია"
jpn "索引名 '%-.100s' は不正です。"
por "Incorreto nome de índice '%-.100s'"
spa "Nombre de índice incorrecto '%-.100s'"
@@ -5363,6 +5642,7 @@ ER_WRONG_NAME_FOR_CATALOG 42000
chi "目录名称'%-.100s'不正确"
eng "Incorrect catalog name '%-.100s'"
ger "Falscher Katalogname '%-.100s'"
+ geo "კატალოგის სახელი ('%-.100s') არასწორია"
jpn "カタログ名 '%-.100s' は不正です。"
por "Incorreto nome de catálogo '%-.100s'"
spa "Nombre de catálogo incorrecto '%-.100s'"
@@ -5371,6 +5651,7 @@ ER_WARN_QC_RESIZE
chi "设置查询缓存值%llu失败;新查询缓存值为%lu"
eng "Query cache failed to set size %llu; new query cache size is %lu"
ger "Änderung der Query-Cache-Größe auf %llu fehlgeschlagen; neue Query-Cache-Größe ist %lu"
+ geo "შეცდომა მოთხოვნების კეშის ზომის %llu-ზე დაყენებისას. ახალი მოთხოვნების კეშის ზომაა %lu"
por "Falha em Query cache para configurar tamanho %llu, novo tamanho de query cache é %lu"
rus "Кеш запросов не может установить размер %llu, новый размер кеша зпросов - %lu"
spa "La caché de consulta (query) ha fallado al poner el tamaño %llu; el nuevo tamaño de caché de consulta (query) es %lu"
@@ -5380,6 +5661,7 @@ ER_BAD_FT_COLUMN
chi "列'%-.192s'不能成为全文索引的一部分"
eng "Column '%-.192s' cannot be part of FULLTEXT index"
ger "Feld '%-.192s' kann nicht Teil eines FULLTEXT-Index sein"
+ geo "'%-.192s' სვეტი FULLTEXT ინდექსის ნაწილი ვერ იქნება"
jpn "列 '%-.192s' は全文索引のキーにはできません。"
por "Coluna '%-.192s' não pode ser parte de índice FULLTEXT"
spa "La columna '%-.192s' no puede format parte de índice FULLTEXT"
@@ -5388,6 +5670,7 @@ ER_UNKNOWN_KEY_CACHE
chi "未知索引缓存'%-.100s'"
eng "Unknown key cache '%-.100s'"
ger "Unbekannter Schlüssel-Cache '%-.100s'"
+ geo "უცნობი გასაღების კეში '%-.100s'"
jpn "'%-.100s' は不明なキーキャッシュです。"
por "Key cache desconhecida '%-.100s'"
spa "Caché de clave desconocida '%-.100s'"
@@ -5396,6 +5679,7 @@ ER_WARN_HOSTNAME_WONT_WORK
chi "MariaDB以-skip-name-resolve模式启动;想用grant,您必须重新启动,不用这个选项"
eng "MariaDB is started in --skip-name-resolve mode; you must restart it without this switch for this grant to work"
ger "MariaDB wurde mit --skip-name-resolve gestartet. Diese Option darf nicht verwendet werden, damit diese Rechtevergabe möglich ist"
+ geo "MariaDB გაშვებულია რეჟიმში --skip-name-resolve. ამ GRANT-მა რომ იმუშაოს, სერვერი ამ პარამეტრის გარეშე უნდა იყოს გაშვებული"
jpn "MariaDBは --skip-name-resolve モードで起動しています。このオプションを外して再起動しなければ、この権限操作は機能しません。"
por "MariaDB foi inicializado em modo --skip-name-resolve. Você necesita reincializá-lo sem esta opção para este grant funcionar"
spa "MariaDB ha sido arrancada en modo --skip-name-resolve; vd necesita reinicializarla sin esta opción para que esta concesión funcione"
@@ -5403,6 +5687,7 @@ ER_UNKNOWN_STORAGE_ENGINE 42000
chi "未知的存储引擎'%s'"
eng "Unknown storage engine '%s'"
ger "Unbekannte Speicher-Engine '%s'"
+ geo "უცნობი საცავის ძრავა '%s'"
hindi "अज्ञात स्टोरेज इंजन '%s'"
jpn "'%s' は不明なストレージエンジンです。"
por "Motor de tabela desconhecido '%s'"
@@ -5411,6 +5696,7 @@ ER_WARN_DEPRECATED_SYNTAX
chi "弃用'%s',将在将来的版本中删除。请使用%s"
eng "'%s' is deprecated and will be removed in a future release. Please use %s instead"
ger "'%s' ist veraltet. Bitte benutzen Sie '%s'"
+ geo "'%s' მოძველებულია და მომავალში ამოღებული იქნება. გამოიყენეთ %s"
jpn "'%s' は将来のリリースで廃止予定です。代わりに %s を使用してください。"
por "'%s' é desatualizado. Use '%s' em seu lugar"
spa "'%s' está obsoleto y será quitado en una entrega futura, use '%s' en su lugar"
@@ -5418,6 +5704,7 @@ ER_NON_UPDATABLE_TABLE
chi "目标表%-.100s多个%s不可更新"
eng "The target table %-.100s of the %s is not updatable"
ger "Die Zieltabelle %-.100s von %s ist nicht aktualisierbar"
+ geo "სამიზნე ცხრილი %-.100s, რომელიც %s-ის ნაწილია, განახლებადი არაა"
jpn "対象表 %-.100s は更新可能ではないので、%s を行えません。"
por "A tabela destino %-.100s do %s não é atualizável"
rus "Таблица %-.100s в %s не может изменятся"
@@ -5428,6 +5715,7 @@ ER_FEATURE_DISABLED
chi "'%s'功能被禁用;您需要MariaDB以'%s'构建以使其工作"
eng "The '%s' feature is disabled; you need MariaDB built with '%s' to have it working"
ger "Das Feature '%s' ist ausgeschaltet, Sie müssen MariaDB mit '%s' übersetzen, damit es verfügbar ist"
+ geo "ფუნქცია '%s' გამორთულია. ასამუშავებლად MariaDB '%s'-ის მხარდაჭერით უნდა ააგოთ"
jpn "機能 '%s' は無効です。利用するためには '%s' を含めてビルドしたMariaDBが必要です。"
por "O recurso '%s' foi desativado; você necessita MariaDB construído com '%s' para ter isto funcionando"
spa "La característica '%s' fue deshabilitada; usted necesita construir MariaDB con '%s' para tener eso funcionando"
@@ -5436,6 +5724,7 @@ ER_OPTION_PREVENTS_STATEMENT
chi "MariaDB服务器使用%s选项运行,因此无法执行此语句"
eng "The MariaDB server is running with the %s option so it cannot execute this statement"
ger "Der MariaDB-Server läuft mit der Option %s und kann diese Anweisung deswegen nicht ausführen"
+ geo "MariaDB სერვერი %s პარამეტრითაა გაშვებული და ამ გამოსახულების შესრულება არ შეუძლია"
jpn "MariaDBサーバーが %s オプションで実行されているので、このステートメントは実行できません。"
por "O servidor MariaDB está rodando com a opção %s razão pela qual não pode executar esse commando"
spa "El servidor MariaDB se está ejecutando con la opción %s por lo que no se puede ejecutar esta sentencia"
@@ -5444,6 +5733,7 @@ ER_DUPLICATED_VALUE_IN_TYPE
chi "列'%-.100s'有重复的值'%-.64s'在%s"
eng "Column '%-.100s' has duplicated value '%-.64s' in %s"
ger "Feld '%-.100s' hat doppelten Wert '%-.64s' in %s"
+ geo "სვეტს '%-.100s' გააჩნია დუბლირებული მნიშვნელობა '%-.64s' %s-ში"
jpn "列 '%-.100s' で、重複する値 '%-.64s' が %s に指定されています。"
por "Coluna '%-.100s' tem valor duplicado '%-.64s' em %s"
spa "La columna '%-.100s' tiene valor duplicado '%-.64s' en %s"
@@ -5451,6 +5741,7 @@ ER_TRUNCATED_WRONG_VALUE 22007
chi "截断的不正确%-.32T值:'%-.128T'"
eng "Truncated incorrect %-.32T value: '%-.128T'"
ger "Falscher %-.32T-Wert gekürzt: '%-.128T'"
+ geo "წაკვეთილია არასწორი %-.32T მნიშვნელობა: '%-.128T'"
jpn "不正な %-.32T の値が切り捨てられました。: '%-.128T'"
por "Truncado errado %-.32T valor: '%-.128T'"
spa "Truncado incorrecto %-.32T valor: '%-.128T'"
@@ -5458,6 +5749,7 @@ ER_TOO_MUCH_AUTO_TIMESTAMP_COLS
chi "表定义不正确;默认或ON UPDATE中只能有一个带有CURRENT_TIMESTAMP的TIMESTAMP列"
eng "Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
ger "Fehlerhafte Tabellendefinition. Es kann nur eine einzige TIMESTAMP-Spalte mit CURRENT_TIMESTAMP als DEFAULT oder in einer ON-UPDATE-Klausel geben"
+ geo "ცხრილის არასწორი აღწერა. DEFAULT ან ON UPDATE პირობაში CURRENT TIMESTAMP-ით მხოლოდ ერთი TIMESTAMP სვეტი შეიძლება არსებობდეს"
jpn "不正な表定義です。DEFAULT句またはON UPDATE句に CURRENT_TIMESTAMP をともなうTIMESTAMP型の列は1つまでです。"
por "Incorreta definição de tabela; Pode ter somente uma coluna TIMESTAMP com CURRENT_TIMESTAMP em DEFAULT ou ON UPDATE cláusula"
spa "Definición incorrecta de tabla; solamente puede haber una columna TIMESTAMP con CURRENT_TIMESTAMP en DEFAULT o en cláusula ON UPDATE"
@@ -5465,6 +5757,7 @@ ER_INVALID_ON_UPDATE
chi "在'%-.192s'列的ON UPDATE子句上无效"
eng "Invalid ON UPDATE clause for '%-.192s' column"
ger "Ungültige ON-UPDATE-Klausel für Spalte '%-.192s'"
+ geo "არასწორი ON UPDATE პირობა '%-.192s' სვეტისთვის"
jpn "列 '%-.192s' に ON UPDATE句は無効です。"
por "Inválida cláusula ON UPDATE para campo '%-.192s'"
spa "Cláusula ON UPDATE inválida para la columna '%-.192s'"
@@ -5472,12 +5765,14 @@ ER_UNSUPPORTED_PS
chi "尚未在prepared statement协议中支持此命令"
eng "This command is not supported in the prepared statement protocol yet"
ger "Dieser Befehl wird im Protokoll für vorbereitete Anweisungen noch nicht unterstützt"
+ geo "ეს ბრძანება მომზადებული გამოსახულების პროტოკოლშიჯერ მხარდაჭერილი არაა"
spa "Este comando no se encuentra soportado para protocolo de sentencia preparada, aún"
ER_GET_ERRMSG
chi "出错%d '%-.200s'来自%s"
dan "Modtog fejl %d '%-.200s' fra %s"
eng "Got error %d '%-.200s' from %s"
ger "Fehler %d '%-.200s' von %s"
+ geo "მიღებულია შეცდომა %d '%-.200s' %s-დან"
jpn "エラー %d '%-.200s' が %s から返されました。"
nor "Mottok feil %d '%-.200s' fa %s"
norwegian-ny "Mottok feil %d '%-.200s' fra %s"
@@ -5487,6 +5782,7 @@ ER_GET_TEMPORARY_ERRMSG
dan "Modtog temporary fejl %d '%-.200s' fra %s"
eng "Got temporary error %d '%-.200s' from %s"
ger "Temporärer Fehler %d '%-.200s' von %s"
+ geo "მიღებულია დროებითი შეცდომა %d '%-.200s' %s-დან"
jpn "一時エラー %d '%-.200s' が %s から返されました。"
nor "Mottok temporary feil %d '%-.200s' fra %s"
norwegian-ny "Mottok temporary feil %d '%-.200s' fra %s"
@@ -5495,227 +5791,270 @@ ER_UNKNOWN_TIME_ZONE
chi "未知或不正确的时区:'%-.64s'"
eng "Unknown or incorrect time zone: '%-.64s'"
ger "Unbekannte oder falsche Zeitzone: '%-.64s'"
+ geo "უცნობი ან არასწორი დროის სარტყელი: '%-.64s'"
spa "Zona temporal desconocida o incorrecta: '%-.64s'"
ER_WARN_INVALID_TIMESTAMP
chi "无效TIMESTAMP值:列'%s' 行'%lu'"
eng "Invalid TIMESTAMP value in column '%s' at row %lu"
ger "Ungültiger TIMESTAMP-Wert in Feld '%s', Zeile %lu"
+ geo "TIMESTAMP-ის არასწორი მნიშვნელობა სვეტში '%s' მწკრივში %lu"
spa "Valor inválido de SELLO TEMPORAL (TIMESTAMP) en la columna '%s' de la fila %lu"
ER_INVALID_CHARACTER_STRING
chi "无效的%s字符串:'%.64T'"
eng "Invalid %s character string: '%.64T'"
ger "Ungültiger %s-Zeichen-String: '%.64T'"
+ geo "არასწორი %s სტრიქონი: '%.64T'"
spa "Cadena de carácter %s inválida: '%.64T'"
ER_WARN_ALLOWED_PACKET_OVERFLOWED
chi "%s()的结果大于max_allowed_packet(%ld) - 截断"
eng "Result of %s() was larger than max_allowed_packet (%ld) - truncated"
ger "Ergebnis von %s() war größer als max_allowed_packet (%ld) Bytes und wurde deshalb gekürzt"
+ geo "%s()-ის პასუხი max_allowed_packet-ზე (%ld) დიდია - წაკვეთა"
spa "El resultado de %s() ha sido mayor que max_allowed_packet (%ld) - truncado"
ER_CONFLICTING_DECLARATIONS
chi "矛盾语句:'%s%s'和'%s%s'"
eng "Conflicting declarations: '%s%s' and '%s%s'"
ger "Widersprüchliche Deklarationen: '%s%s' und '%s%s'"
+ geo "კონფლიქტური აღწერები: '%s%s' და '%s%s'"
spa "Declaraciones conflictivas: '%s%s' y '%s%s'"
ER_SP_NO_RECURSIVE_CREATE 2F003
chi "无法从另一个存储过程中创建%s"
eng "Can't create a %s from within another stored routine"
ger "Kann kein %s innerhalb einer anderen gespeicherten Routine erzeugen"
+ geo "%s-ის სხვა დამახსოვრებულ ქვეპროგრამიდან შექმნა შეუძლებელია"
spa "No puedo crear una %s desde dentro de otra rutina almacenada"
ER_SP_ALREADY_EXISTS 42000
chi "%s%s已经存在"
eng "%s %s already exists"
ger "%s %s existiert bereits"
+ geo "%s %s უკვე არსებობს"
hindi "%s %s पहले से ही मौजूद है"
spa "%s %s ya existe"
ER_SP_DOES_NOT_EXIST 42000
chi "%s%s不存在"
eng "%s %s does not exist"
ger "%s %s existiert nicht"
+ geo "%s %s არ არსებობს"
hindi "%s %s मौजूद नहीं है"
spa "%s %s no existe"
ER_SP_DROP_FAILED
chi "未能DROP%s%s"
eng "Failed to DROP %s %s"
ger "DROP %s %s ist fehlgeschlagen"
+ geo "%s %s-ის DROP შეუძლებელია"
hindi "%s %s को ड्रॉप करने में असफल रहे"
spa "No pude ELIMINAR (DROP) %s %s"
ER_SP_STORE_FAILED
chi "无法创建%s%s"
eng "Failed to CREATE %s %s"
ger "CREATE %s %s ist fehlgeschlagen"
+ geo "%s %s-ის CREATE შეუძლებელია"
hindi "%s %s को बनाने में असफल रहे"
spa "No pude CREAR %s %s"
ER_SP_LILABEL_MISMATCH 42000
chi "%s,没有匹配标签:%s"
eng "%s with no matching label: %s"
ger "%s ohne passende Marke: %s"
+ geo "%s-ს ჭდე არ ემთხვევა: %s"
spa "%s sin etiqueta coincidente: %s"
ER_SP_LABEL_REDEFINE 42000
chi "重新定义标签%s"
eng "Redefining label %s"
ger "Neudefinition der Marke %s"
+ geo "ჭდე %s თავიდ აღიწერა"
spa "Redefiniendo etiqueta %s"
ER_SP_LABEL_MISMATCH 42000
chi "没有匹配的最终标签%s"
eng "End-label %s without match"
ger "Ende-Marke %s ohne zugehörigen Anfang"
+ geo "ბოლო-ჭდე %s დამთხვევის გარეშე"
spa "Etiqueta-Final %s sin coincidencia"
ER_SP_UNINIT_VAR 01000
chi "参考未初始化的变量%s"
eng "Referring to uninitialized variable %s"
ger "Zugriff auf nichtinitialisierte Variable %s"
+ geo "მიმართვა არაინიციალიზებულ ცვლადზე %s"
spa "Refiriéndose a variable %s sin inicializar"
ER_SP_BADSELECT 0A000
chi "PROCEDURE%s不能返回给定上下文中的结果集"
eng "PROCEDURE %s can't return a result set in the given context"
ger "PROCEDURE %s kann im gegebenen Kontext keine Ergebnismenge zurückgeben"
+ geo "PROCEDURE %s-ს მითითებულ კონტექსტში პასუხის დაბრუნება არ შეუძლია"
spa "El PROCEDIMIENTO (PROCEDURE) %s no puede devolver un conjunto de resultados en el contexto dado"
ER_SP_BADRETURN 42000
chi "RETURN仅允许在函数中"
eng "RETURN is only allowed in a FUNCTION"
ger "RETURN ist nur innerhalb einer FUNCTION erlaubt"
+ geo "RETURN მხოლოდ FUNCTION-შია დაშვებული"
hindi "RETURN को केवल FUNCTION में इस्तेमाल किया जा सकता है"
spa "RETURN sólo se permite dentro de una FUNCIÓN"
ER_SP_BADSTATEMENT 0A000
chi "%s不允许在存储过程中"
eng "%s is not allowed in stored procedures"
ger "%s ist in gespeicherten Prozeduren nicht erlaubt"
+ geo "%s დამახსოვრებულ პროცედურებში დაშვებული არაა"
hindi "%s को STORED PROCEDURE में इस्तेमाल नहीं किया जा सकता है"
spa "%s no permitido en procedimientos almacenados"
ER_UPDATE_LOG_DEPRECATED_IGNORED 42000
chi "更新日志被弃用并由二进制日志替换;SET SQL_LOG_UPDATE已被忽略。此选项将在MariaDB 5.6中删除"
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored. This option will be removed in MariaDB 5.6"
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wird ignoriert. Diese Option wird in MariaDB 5.6 entfernt"
+ geo "Update-Log მოძველებულია და ხდება მისი ჩანაცვლება Binary-Log-ით. SET SQL LOG UPDATE იგნორირებულია. ეს პარამეტრი წაიშლება MariaDB-ის ვერსიაში 5.6"
spa "El historial (log) de actualización se encuentra obsoleto y reemplazado por el historial (log) binario; SET SQL_LOG_UPDATE ha sido ignorado. Esta opción será quitada en MariaDB 5.6"
ER_UPDATE_LOG_DEPRECATED_TRANSLATED 42000
chi "更新日志被弃用并由二进制日志替换;SET SQL_LOG_UPDATE已被转换为设置SQL_LOG_BIN。此选项将在MariaDB 5.6中删除"
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN. This option will be removed in MariaDB 5.6"
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wurde in SET SQL_LOG_BIN übersetzt. Diese Option wird in MariaDB 5.6 entfernt"
+ geo "Update-Log მოძველებულია და ხდება მისი ჩანაცვლება Binary-Log-ით. SET SQL_LOG_UPGRATE გარდაიქმნა SET SQL_LOG_BIN პარამეტრად. ეს პარამეტრი წაიშლება MariaDB-ის ვერსიაში 5.6"
spa "El historial (log) de actualización se encuentra obsoleto y reemplazado por el historial binario; SET SQL_LOG_UPDATE ha sido traducido a SET SQL_LOG_BIN. Esta opción será quitada en MariaDB 5.6"
ER_QUERY_INTERRUPTED 70100
chi "查询执行中断"
eng "Query execution was interrupted"
ger "Ausführung der Abfrage wurde unterbrochen"
+ geo "მოთხოვნის შესრულება შეწყვეტილია"
spa "Se ha interrumpido la ejecución de la consulta (query)"
ER_SP_WRONG_NO_OF_ARGS 42000
chi "%s%s的参数数量不正确;预期%u,得到%u"
eng "Incorrect number of arguments for %s %s; expected %u, got %u"
ger "Falsche Anzahl von Argumenten für %s %s; erwarte %u, erhalte %u"
+ geo "%s %s-ის არგუმენტების არასწორი რაოდენობა. მოველოდი %u-ს, მივიღე %u"
spa "Número incorrecto de argumentos para %s %s; se esperaba %u, se obtuvo %u"
ER_SP_COND_MISMATCH 42000
chi "未定义的CONDITION:%s"
eng "Undefined CONDITION: %s"
ger "Undefinierte CONDITION: %s"
+ geo "განუსაზღვრელი CONDITION: %s"
spa "CONDICIÓN no definida: %s"
ER_SP_NORETURN 42000
chi "FUNCTION%s中没有RETURN"
eng "No RETURN found in FUNCTION %s"
ger "Kein RETURN in FUNCTION %s gefunden"
+ geo "ფუნქციაში %s RETURN ვერ ვიპოვე"
hindi "FUNCTION %s में कोई RETURN है"
spa "No se hallado RETURN en FUNCIÓN %s"
ER_SP_NORETURNEND 2F005
chi "FUNCTION%s结束但无RETURN"
eng "FUNCTION %s ended without RETURN"
ger "FUNCTION %s endete ohne RETURN"
+ geo "FUNCTION %s დასრულდა RETURN-ის გარეშე"
hindi "FUNCTION %s RETURN के बिना समाप्त हो गया"
spa "La FUNCIÓN %s termina sin RETURN"
ER_SP_BAD_CURSOR_QUERY 42000
chi "Cursor语句必须是选择"
eng "Cursor statement must be a SELECT"
ger "Cursor-Anweisung muss ein SELECT sein"
+ geo "კურსორის გამოსახულება SELECT-ს უნდა წარმოადგენდეს"
spa "La sentencia de cursor debe de ser un SELECT"
ER_SP_BAD_CURSOR_SELECT 42000
chi "Cursor SELECT不能有INTO"
eng "Cursor SELECT must not have INTO"
ger "Cursor-SELECT darf kein INTO haben"
+ geo "Cursor-Select-ი არ შეიძლება, INTO-ს შეიცავდეს"
spa "El SELECT de cursor no debe de tener INTO"
ER_SP_CURSOR_MISMATCH 42000
chi "未定义的CURSOR:%s"
eng "Undefined CURSOR: %s"
ger "Undefinierter CURSOR: %s"
+ geo "აღუწერელი CURSOR: %s"
hindi "CURSOR %s अपरिभाषित है"
spa "CURSOR indefinido: %s"
ER_SP_CURSOR_ALREADY_OPEN 24000
chi "Cursor已经打开"
eng "Cursor is already open"
ger "Cursor ist schon geöffnet"
+ geo "CURSOR-ი უკვე ღიაა"
hindi "CURSOR पहले से ही खुला है"
spa "Cursor ya abierto"
ER_SP_CURSOR_NOT_OPEN 24000
chi "Cursor未打开"
eng "Cursor is not open"
ger "Cursor ist nicht geöffnet"
+ geo "Cursor-ი ღია არაა"
spa "Cursor no abierto"
ER_SP_UNDECLARED_VAR 42000
chi "未定义的变量:%s"
eng "Undeclared variable: %s"
ger "Nicht deklarierte Variable: %s"
+ geo "ცვლადი აღწერილი არაა: %s"
spa "Variable sin declarar: %s"
ER_SP_WRONG_NO_OF_FETCH_ARGS
chi "FETCH变量数不正确"
eng "Incorrect number of FETCH variables"
ger "Falsche Anzahl von FETCH-Variablen"
+ geo "FETCH-ის ცვლადების არასწორი რაოდენობა"
spa "Incorrecto número de variables FETCH"
ER_SP_FETCH_NO_DATA 02000
chi "没有数据 - 零行被选择或处理"
eng "No data - zero rows fetched, selected, or processed"
ger "Keine Daten - null Zeilen geholt (fetch), ausgewählt oder verarbeitet"
+ geo "მონაცემების გარეშე - მიღებულია, არჩეულია ან დამუშავებულია 0 ჩანაწერი"
spa "No hay datos - cero filas logradas, seleccionadas o procesadas"
ER_SP_DUP_PARAM 42000
chi "重复参数:%s"
eng "Duplicate parameter: %s"
ger "Doppelter Parameter: %s"
+ geo "დუბლირებული პარამეტრი: %s"
spa "Parámetro duplicado: %s"
ER_SP_DUP_VAR 42000
chi "重复变量:%s"
eng "Duplicate variable: %s"
ger "Doppelte Variable: %s"
+ geo "დუბლირებული ცვლადი: %s"
spa "Variable duplicada: %s"
ER_SP_DUP_COND 42000
chi "重复条件:%s"
eng "Duplicate condition: %s"
ger "Doppelte Bedingung: %s"
+ geo "დუბლირებული პირობა: %s"
spa "Condición duplicada: %s"
ER_SP_DUP_CURS 42000
chi "重复Cursor:%s"
eng "Duplicate cursor: %s"
ger "Doppelter Cursor: %s"
+ geo "დუბლირებული კურსორი: %s"
spa "Cursor duplicado: %s"
ER_SP_CANT_ALTER
chi "未能ALTER %s%s"
eng "Failed to ALTER %s %s"
ger "ALTER %s %s fehlgeschlagen"
+ geo "%s %s-ის ALTER-ის შეცდომა"
hindi "%s %s को ALTER करने में असफल रहे"
spa "Fallo en ALTER %s %s"
ER_SP_SUBSELECT_NYI 0A000
chi "不支持子查询值"
eng "Subquery value not supported"
ger "Subquery-Wert wird nicht unterstützt"
+ geo "ქვემოთხოვნის მნიშვნელობა მხარდაუჭერელია"
spa "Valor de Subconsulta (subquery) no soportado"
ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG 0A000
chi "在存储的函数或触发中不允许%s"
eng "%s is not allowed in stored function or trigger"
ger "%s ist in gespeicherten Funktionen und in Triggern nicht erlaubt"
+ geo "%s დამახსოვრებულ ფუნქციაში და ტრიგერში დაშვებული არაა"
spa "%s no permitido en función almacenada o en disparador"
ER_SP_VARCOND_AFTER_CURSHNDLR 42000
chi "变量或条件声明在cursor或处理程序定义之后"
eng "Variable or condition declaration after cursor or handler declaration"
ger "Deklaration einer Variablen oder einer Bedingung nach der Deklaration eines Cursors oder eines Handlers"
+ geo "ცვლადის ან პირობის აღწერა კურსორის ან დამმუშავებლის აღწერის შემდეგ"
spa "Declaración de variable o condición tras declaración de cursor o manejador"
ER_SP_CURSOR_AFTER_HANDLER 42000
chi "处理程序声明后的cursor声明"
eng "Cursor declaration after handler declaration"
ger "Deklaration eines Cursors nach der Deklaration eines Handlers"
+ geo "კურსორის აღწერა დამმუშავებლის აღწერის შემდეგ"
spa "Declaración de cursor tras declaración de manejador"
ER_SP_CASE_NOT_FOUND 20000
chi "未能在CASE语句找到Case"
eng "Case not found for CASE statement"
ger "Fall für CASE-Anweisung nicht gefunden"
+ geo "CASE გამოსახულებისთვის პირობა ვერ ვიპოვე"
spa "Caso no hallado para sentencia CASE"
ER_FPARSER_TOO_BIG_FILE
chi "配置文件'%-.192s'太大了"
eng "Configuration file '%-.192s' is too big"
ger "Konfigurationsdatei '%-.192s' ist zu groß"
+ geo "კონფიგურაციის ფაილი '%-.192s' ძალიან დიდია"
rus "Слишком большой конфигурационный файл '%-.192s'"
spa "El fichero/archivo de configuración '%-.192s' es demasiado grande"
ukr "Занадто великий конфігураційний файл '%-.192s'"
@@ -5723,6 +6062,7 @@ ER_FPARSER_BAD_HEADER
chi "文件'%-.192s'中的文件类型格式有问题"
eng "Malformed file type header in file '%-.192s'"
ger "Nicht wohlgeformter Dateityp-Header in Datei '%-.192s'"
+ geo "ფაილის ტიპის არასწორი თავსართი ფაილში '%-.192s'"
rus "Неверный заголовок типа файла '%-.192s'"
spa "Cabecera de tipo de fichero/archivo malformada en fichero/archivo '%-.192s'"
ukr "Невірний заголовок типу у файлі '%-.192s'"
@@ -5730,6 +6070,7 @@ ER_FPARSER_EOF_IN_COMMENT
chi "解析评论'%-.200s'时意外碰到EOF"
eng "Unexpected end of file while parsing comment '%-.200s'"
ger "Unerwartetes Dateiende beim Parsen des Kommentars '%-.200s'"
+ geo "ფაილის მოულოდნელი დასასრული კომენტარის დამუშავებისას '%-.200s'"
rus "Неожиданный конец файла в коментарии '%-.200s'"
spa "Inesperado fin de fichero/archivo mientras se analizaba comentario '%-.200s'"
ukr "Несподіванний кінець файлу у коментарі '%-.200s'"
@@ -5737,6 +6078,7 @@ ER_FPARSER_ERROR_IN_PARAMETER
chi "解析参数'%-.192s'时出错(行:'%-.192s')"
eng "Error while parsing parameter '%-.192s' (line: '%-.192s')"
ger "Fehler beim Parsen des Parameters '%-.192s' (Zeile: '%-.192s')"
+ geo "შეცდომა პარამეტრის ('%-.192s') დამუშავებისას (ხაზი: '%-.192s')"
rus "Ошибка при распознавании параметра '%-.192s' (строка: '%-.192s')"
spa "Error mientras se analizaba parámetro '%-.192s' (línea: '%-.192s')"
ukr "Помилка в роспізнаванні параметру '%-.192s' (рядок: '%-.192s')"
@@ -5744,6 +6086,7 @@ ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER
chi "跳过未知参数'%-.192s'时意外碰到EOF"
eng "Unexpected end of file while skipping unknown parameter '%-.192s'"
ger "Unerwartetes Dateiende beim Überspringen des unbekannten Parameters '%-.192s'"
+ geo "ფაილის მოულოდნელი დასასრული უცნობი პარამეტრის (%-.192s') დამუშავებისას"
rus "Неожиданный конец файла при пропуске неизвестного параметра '%-.192s'"
spa "Inesperado fin de fichero/archivo mientras se saltaba parámetro desconocido '%-.192s'"
ukr "Несподіванний кінець файлу у спробі проминути невідомий параметр '%-.192s'"
@@ -5751,6 +6094,7 @@ ER_VIEW_NO_EXPLAIN
chi "ANALYZE/EXPLAIN/SHOW无法进行;缺乏底层表的特权"
eng "ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table"
ger "ANALYZE/EXPLAIN/SHOW kann nicht verlangt werden. Rechte für zugrunde liegende Tabelle fehlen"
+ geo "ANALYZE/EXPLAIN/SHOW-ის გაშვება შეუძლებელია. მოთხოვნილ ცხრილზე საკმარისი წვდომები არ გაგაჩნიათ"
rus "ANALYZE/EXPLAIN/SHOW не может быть выполнено; недостаточно прав на таблицы запроса"
spa "ANALYZE/EXPLAIN/SHOW no puede ser emitdo; privilegios insuficientes para tabla subyacente"
ukr "ANALYZE/EXPLAIN/SHOW не може бути виконано; немає прав на таблиці запиту"
@@ -5758,6 +6102,7 @@ ER_FRM_UNKNOWN_TYPE
chi "文件'%-.192s'在其标题中有未知的'%-.64s'"
eng "File '%-.192s' has unknown type '%-.64s' in its header"
ger "Datei '%-.192s' hat unbekannten Typ '%-.64s' im Header"
+ geo "ფაილის '%-.192s' უცნობი ტიპი '%-.64s' მის თავსართში"
rus "Файл '%-.192s' содержит неизвестный тип '%-.64s' в заголовке"
spa "El fichero/archivo '%-.192s' es de un tipo desconocido '%-.64s' en su cabecera"
ukr "Файл '%-.192s' має невідомий тип '%-.64s' у заголовку"
@@ -5765,6 +6110,7 @@ ER_WRONG_OBJECT
chi "'%-.192s.%-.192s'不是'%s'类"
eng "'%-.192s.%-.192s' is not of type '%s'"
ger "'%-.192s.%-.192s' ist nicht %s"
+ geo "'%-.192s.%-.192s'-ი '%s'-ის ტიპს არ წარმოადგენს"
rus "'%-.192s.%-.192s' - не %s"
spa "'%-.192s.%-.192s' no es del tipo '%s'"
ukr "'%-.192s.%-.192s' не є %s"
@@ -5772,6 +6118,7 @@ ER_NONUPDATEABLE_COLUMN
chi "列'%-.192s'不可更新"
eng "Column '%-.192s' is not updatable"
ger "Feld '%-.192s' ist nicht aktualisierbar"
+ geo "სვეტი '%-.192s' განახლებადი არაა"
rus "Столбец '%-.192s' не обновляемый"
spa "La columna '%-.192s' no es actualiable"
ukr "Стовбець '%-.192s' не може бути зминений"
@@ -5779,6 +6126,7 @@ ER_VIEW_SELECT_DERIVED
chi "View的Select的FROM包含子查询"
eng "View's SELECT contains a subquery in the FROM clause"
ger "SELECT der View enthält eine Subquery in der FROM-Klausel"
+ geo "View-ის SELECT-ი FROM პირობაში ქვემოთხოვნას შეიცავს"
rus "View SELECT содержит подзапрос в конструкции FROM"
spa "El SELECT de la vista contiene una subconsulta (subquery) en la cláusula FROM"
ukr "View SELECT має підзапит у конструкції FROM"
@@ -5788,6 +6136,7 @@ ER_VIEW_SELECT_CLAUSE
chi "View的Select包含“%s”子句"
eng "View's SELECT contains a '%s' clause"
ger "SELECT der View enthält eine '%s'-Klausel"
+ geo "View-ის SELECT შეიცავს პირობას '%s'"
rus "View SELECT содержит конструкцию '%s'"
spa "El SELECT de la vista contiene una cláusula '%s'"
ukr "View SELECT має конструкцію '%s'"
@@ -5795,6 +6144,7 @@ ER_VIEW_SELECT_VARIABLE
chi "View的选择包含变量或参数"
eng "View's SELECT contains a variable or parameter"
ger "SELECT der View enthält eine Variable oder einen Parameter"
+ geo "View-ის SELECT-ი ცვლადს ან პარამეტრს შეიცავს"
rus "View SELECT содержит переменную или параметр"
spa "El SELECT de la vista contiene una variable o un parámetro"
ukr "View SELECT має зминну або параметер"
@@ -5802,6 +6152,7 @@ ER_VIEW_SELECT_TMPTABLE
chi "View的SELECT指的是临时表'%-.192s'"
eng "View's SELECT refers to a temporary table '%-.192s'"
ger "SELECT der View verweist auf eine temporäre Tabelle '%-.192s'"
+ geo "View-ის SELECT-ი დროებით ცხრილზე '%-.192s' მიმართვას შეიცავს"
rus "View SELECT содержит ссылку на временную таблицу '%-.192s'"
spa "El SELECT de la vista se refiere a una tabla temporal '%-.192s'"
ukr "View SELECT використовує тимчасову таблицю '%-.192s'"
@@ -5809,6 +6160,7 @@ ER_VIEW_WRONG_LIST
chi "View的选择和VIEW的字段列表具有不同的列计数"
eng "View's SELECT and view's field list have different column counts"
ger "SELECT- und Feldliste der Views haben unterschiedliche Anzahlen von Spalten"
+ geo "View-ის SELECT-ი და View-ის ველების სია განსხვავებულ სვეტების რაოდენობას შეიცავენ"
rus "View SELECT и список полей view имеют разное количество столбцов"
spa "El SELECT de la vista y la lista de campos de la vista tienen un contador diferente de columnas"
ukr "View SELECT і перелік стовбців view мають різну кількість сковбців"
@@ -5816,6 +6168,7 @@ ER_WARN_VIEW_MERGE
chi "View合并算法目前不能使用(假设未定义的算法)"
eng "View merge algorithm can't be used here for now (assumed undefined algorithm)"
ger "View-Merge-Algorithmus kann hier momentan nicht verwendet werden (undefinierter Algorithmus wird angenommen)"
+ geo "View-ის შერწყმის ალგორითმს ახლა ვერ გამოიყენებთ (ალგორითმი აღუწერელი იქნება)"
rus "Алгоритм слияния view не может быть использован сейчас (алгоритм будет неопеределенным)"
spa "El algoritmo de fusión de la vista no se puede usar aquí por ahora (se asume algoritmo indefinido)"
ukr "Алгоритм зливання view не може бути використаний зараз (алгоритм буде невизначений)"
@@ -5823,76 +6176,90 @@ ER_WARN_VIEW_WITHOUT_KEY
chi "更新的视图没有底层表的完整键"
eng "View being updated does not have complete key of underlying table in it"
ger "Die aktualisierte View enthält nicht den vollständigen Schlüssel der zugrunde liegenden Tabelle"
+ geo "განახლებადი View მასში გამოყენებული ცხრილის სრულ გასაღებს არ შეიცავს"
rus "Обновляемый view не содержит ключа использованных(ой) в нем таблиц(ы)"
spa "La vista que se está actualizando no tiene clave completa de la tabla subyacente que contiene"
ukr "View, що оновлюеться, не містить повного ключа таблиці(ь), що викорістана в ньюому"
ER_VIEW_INVALID
chi "View'%-.192s.%-.192s'引用无效的表、列、函数、或者函数或View缺乏使用权"
eng "View '%-.192s.%-.192s' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them"
+ geo "View '%-.192s.%-.192s' მიმართავს არასწორ ცხრილებს ან სვეტებს ან ფუნქციებს ან View-ის აღმწერს/ჩამწოდებელს მისი გამოყენების უფლებები არ გააჩნია"
spa "La vista '%-.192s.%-.192s' hace referencia a tabla(s) o columna(s) o función(es) inválida(s) o al definidor/invocador de vista le faltan derechos para usarlos"
ER_SP_NO_DROP_SP
chi "无法从另一个存储的例程中删除或更改%s"
eng "Can't drop or alter a %s from within another stored routine"
ger "Kann eine %s nicht von innerhalb einer anderen gespeicherten Routine löschen oder ändern"
+ geo "%s-ის წაშლა ან შეცვლა სხვა დამახსოვრებული ქვეპროგრამიდან შეუძლებელია"
spa "No puedo eliminar o alterar una %s desde dentro de otra rutina almacenada"
ER_SP_GOTO_IN_HNDLR
chi "在存储过程处理程序中不允许GOTO"
eng "GOTO is not allowed in a stored procedure handler"
ger "GOTO ist im Handler einer gespeicherten Prozedur nicht erlaubt"
+ geo "GOTO დამახსოვრებული პროცედურის დამმუშავებელში დაუშვებელია"
spa "GOTO no permitido en manejador de procedimiento almacenado"
ER_TRG_ALREADY_EXISTS
chi "触发'%s'已经存在"
eng "Trigger '%s' already exists"
ger "Trigger '%s' existiert bereits"
+ geo "ტრიგერი '%s' უკვე არსებობს"
hindi "TRIGGER '%s' पहले से मौजूद है"
spa "Ya existe el disparador `%s`"
ER_TRG_DOES_NOT_EXIST
chi "触发不存在"
eng "Trigger does not exist"
ger "Trigger existiert nicht"
+ geo "ტრიგერი არ არსებობს"
hindi "TRIGGER मौजूद नहीं है"
spa "El disparador no existe"
ER_TRG_ON_VIEW_OR_TEMP_TABLE
chi "触发器的'%-.192s'是视图或临时表"
eng "Trigger's '%-.192s' is a view, temporary table or sequence"
ger "'%-.192s' des Triggers ist ein View, temporäre Tabelle oder Sequence"
+ geo "ტრიგერის '%-.192s' View-ს, დროებით ცხრილს ან მიმდევრობას წარმოადგენს"
spa "El disparador '%-.192s' es una vista, tabla temporal o secuencia"
hindi "Trigger का '%-.192s' एक व्यू, टेम्पररी टेबल या सीक्वेंस है"
ER_TRG_CANT_CHANGE_ROW
chi "更新%s行在%s触发器中不允许"
eng "Updating of %s row is not allowed in %strigger"
ger "Aktualisieren einer %s-Zeile ist in einem %s-Trigger nicht erlaubt"
+ geo "%s მწკრივის განახლება %s ტრიგერში შეუძლებელია"
spa "Actualizar la fila %s no está permitido en disparador %s"
ER_TRG_NO_SUCH_ROW_IN_TRG
chi "没有%s行,触发%s"
eng "There is no %s row in %s trigger"
ger "Es gibt keine %s-Zeile im %s-Trigger"
+ geo "%s მწრივი %s ტრიგერში არ არსებობს"
spa "No hay fila %s en disparador %s"
ER_NO_DEFAULT_FOR_FIELD
chi "字段'%-.192s'没有默认值"
eng "Field '%-.192s' doesn't have a default value"
ger "Feld '%-.192s' hat keinen Vorgabewert"
+ geo "ველს '%-.192s' ნაგულისხმები მნიშვნელობა არ გააჩნია"
spa "El campo '%-.192s' no tiene un valor por defecto"
ER_DIVISION_BY_ZERO 22012
chi "除0错误"
eng "Division by 0"
ger "Division durch 0"
+ geo "ნულზე გაყოფა"
hindi "0 से विभाजन"
spa "División por 0"
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 22007
chi "不正确的%-.32s值:'%-.128T'用于列`%.192s`%.192s`%.192s`在%lu行"
eng "Incorrect %-.32s value: '%-.128T' for column `%.192s`.`%.192s`.`%.192s` at row %lu"
ger "Falscher %-.32s-Wert: '%-.128T' für Feld '`%.192s`.`%.192s`.`%.192s` in Zeile %lu"
+ geo "%-.32s-ის არასწორი მნიშვნელობა '%-.128T' სვეტისთვის `%.192s`.`%.192s`.`%.192s` მწკრივთან %lu"
spa "Incorrecto %-.32s valor: '%-.128T' para columna `%.192s`.`%.192s`.`%.192s` en la fila %lu"
ER_ILLEGAL_VALUE_FOR_TYPE 22007
chi "在解析期间发现的非法%s '%-.192T'值"
eng "Illegal %s '%-.192T' value found during parsing"
ger "Nicht zulässiger %s-Wert '%-.192T' beim Parsen gefunden"
+ geo "დამუშავებისას აღმოჩენილია %s '%-.192T'-ის დაუშვებელი მნიშვნელობა"
spa "Hallado valor ilegal %s '%-.192T' durante el análisi"
ER_VIEW_NONUPD_CHECK
chi "在不可更新的视图%`-.192s.%`-.192s上CHECK OPTION"
eng "CHECK OPTION on non-updatable view %`-.192s.%`-.192s"
ger "CHECK OPTION auf nicht-aktualisierbarem View %`-.192s.%`-.192s"
+ geo "CHECK OPTION განუახლებელი VIEW-სთვის %`-.192s.%`-.192s"
rus "CHECK OPTION для необновляемого VIEW %`-.192s.%`-.192s"
spa "CHECK OPTION en vista no actualizable %`-.192s.%`-.192s"
ukr "CHECK OPTION для VIEW %`-.192s.%`-.192s що не може бути оновленним"
@@ -5900,6 +6267,7 @@ ER_VIEW_CHECK_FAILED 44000
chi "CHECK OPTION失败%`-.192s.%`-.192s"
eng "CHECK OPTION failed %`-.192s.%`-.192s"
ger "CHECK OPTION fehlgeschlagen: %`-.192s.%`-.192s"
+ geo "CHECK OPTION-ის შეცდომა %`-.192s.%`-.192s"
rus "Проверка CHECK OPTION для VIEW %`-.192s.%`-.192s провалилась"
spa "CHECK OPTION falló %`-.192s.%`-.192s"
ukr "Перевірка CHECK OPTION для VIEW %`-.192s.%`-.192s не пройшла"
@@ -5907,117 +6275,140 @@ ER_PROCACCESS_DENIED_ERROR 42000
chi "%-.32s命令被拒绝。用户为'%s'@'%s' 例程'%-.192s'"
eng "%-.32s command denied to user '%s'@'%s' for routine '%-.192s'"
ger "Befehl %-.32s nicht zulässig für Benutzer '%s'@'%s' in Routine '%-.192s'"
+ geo "%-.32s ბრძანება აკრძალულია მომხმარებლისთვის '%s'@'%s' ქვეპროგრამისთვის '%-.192s'"
spa "Comando %-.32s denegado para el usuario '%s'@'%s' para rutina '%-.192s'"
ER_RELAY_LOG_FAIL
chi "清除旧继relay日志失败:%s"
eng "Failed purging old relay logs: %s"
ger "Bereinigen alter Relais-Logs fehlgeschlagen: %s"
+ geo "ძველი Relay-Log-ის წაშლის შეცდომა: %s"
spa "Falló la purga de viejos historiales (logs) de reenvío: %s"
ER_PASSWD_LENGTH
chi "密码哈希应该是一个%d-digit十六进制数"
eng "Password hash should be a %d-digit hexadecimal number"
ger "Passwort-Hash sollte eine Hexdaezimalzahl mit %d Stellen sein"
+ geo "პაროლი %d-ციფრიან თექვსმეტობით რიცხვს უნდა წარმოადგენდეს"
spa "El valor calculado de la contraseña debería de ser un número hexadecimal de %d-dígitos"
ER_UNKNOWN_TARGET_BINLOG
chi "在Binlog索引中找不到目标日志"
eng "Target log not found in binlog index"
ger "Ziel-Log im Binlog-Index nicht gefunden"
+ geo "სამიზნე ჟურნალი binlog-ის ინდექსში აღმოჩენილი არაა"
spa "Historial (log) de destino no hallado en índice binlog"
ER_IO_ERR_LOG_INDEX_READ
chi "读取日志索引文件时I/O错误"
eng "I/O error reading log index file"
ger "Fehler beim Lesen der Log-Index-Datei"
+ geo "შეტ/გამოტ შეცდომა ჟურნალის ინდექსის ფაილის კითხვისას"
spa "Error de E/S leyendo fichero/archivo índice de historial (log)"
ER_BINLOG_PURGE_PROHIBITED
chi "服务器配置不允许Binlog清除"
eng "Server configuration does not permit binlog purge"
ger "Server-Konfiguration erlaubt keine Binlog-Bereinigung"
+ geo "სერვერის კონფიგურაცია Binlog ჟურნალის წაშლის უფლებას არ იძლევა"
spa "La configuración del servidor no permite purgar binlog"
ER_FSEEK_FAIL
chi "fseek()失败"
eng "Failed on fseek()"
ger "fseek() fehlgeschlagen"
+ geo "fseek()-ის შეცდომა"
hindi "fseek() विफल रहा"
spa "Fallo en fseek()"
ER_BINLOG_PURGE_FATAL_ERR
chi "日志清除期间的致命错误"
eng "Fatal error during log purge"
ger "Schwerwiegender Fehler bei der Log-Bereinigung"
+ geo "ფატალური შეცდომა ჟურნალის წაშლისას"
spa "Error fatal durante la purga del historial (log)"
ER_LOG_IN_USE
chi "日志在用,不会清除"
eng "A purgeable log is in use, will not purge"
ger "Ein zu bereinigendes Log wird gerade benutzt, daher keine Bereinigung"
+ geo "წასაშლელი ჟურნალი უკვე გამოიყენება. არ წაიშლება"
spa "Se encuentra en uso un historial purgable, no lo purgaré"
ER_LOG_PURGE_UNKNOWN_ERR
chi "日志清除期间未知错误"
eng "Unknown error during log purge"
ger "Unbekannter Fehler bei Log-Bereinigung"
+ geo "უცნობი შეცდომა ჟურნალის წაშლისას"
spa "Error desconocido durante la purga del historial (log)"
ER_RELAY_LOG_INIT
chi "初始化relay日志失败。位置:%s"
eng "Failed initializing relay log position: %s"
ger "Initialisierung der Relais-Log-Position fehlgeschlagen: %s"
+ geo "Relay-Log-ის მდებარეობის ინიციალიზაციის შეცდომა: %s"
spa "Fallo inicializando la posición del historial de reenvío: %s"
ER_NO_BINARY_LOGGING
chi "您不使用二进制日志记录"
eng "You are not using binary logging"
ger "Sie verwenden keine Binärlogs"
+ geo "თქვენ Binary-Log-ს არ იყენებთ"
spa "No está usando historial (log) binario"
ER_RESERVED_SYNTAX
chi "'%-.64s'语法保留用于MariaDB服务器内部"
eng "The '%-.64s' syntax is reserved for purposes internal to the MariaDB server"
ger "Die Schreibweise '%-.64s' ist für interne Zwecke des MariaDB-Servers reserviert"
+ geo "'%-.64s' სინტაქსი MariaDB სერვერის შიდა მოხმარებისთვის გამოიყენება"
spa "La sintaxis '%-.64s' está reservada para propósitos internos del servidor MariaDB"
ER_WSAS_FAILED
chi "WSAStartup失败了"
eng "WSAStartup Failed"
ger "WSAStartup fehlgeschlagen"
+ geo "WSAStartup-ის შეცდომა"
spa "Falló WSAStartup"
ER_DIFF_GROUPS_PROC
chi "无法处理具有不同组的过程"
eng "Can't handle procedures with different groups yet"
ger "Kann Prozeduren mit unterschiedlichen Gruppen noch nicht verarbeiten"
+ geo "სხვაადსხვა ჯგუფების მქონე პროცედურების დამუშავება ჯერ შეუძლებელია"
spa "No puedo manejar procedimientos con grupos diferentes, aún"
ER_NO_GROUP_FOR_PROC
chi "SELECT必须具有此过程的组"
eng "Select must have a group with this procedure"
ger "SELECT muss bei dieser Prozedur ein GROUP BY haben"
+ geo "ამ პროცედურაში SELECT-ს ჯგუფი უნდა ჰქონდეს"
spa "La selección debe de tener un grupo con este procedimiento"
ER_ORDER_WITH_PROC
chi "无法在次存储过程使用ORDER子句"
eng "Can't use ORDER clause with this procedure"
ger "Kann bei dieser Prozedur keine ORDER-BY-Klausel verwenden"
+ geo "ამ პროცედურაში ORDER პირობას ვერ გამოიყენებთ"
spa "No puedo usar la cláusula ORDER con este procedimiento"
ER_LOGGING_PROHIBIT_CHANGING_OF
chi "二进制日志记录和复制禁止更改全局服务器%s"
eng "Binary logging and replication forbid changing the global server %s"
ger "Binärlogs und Replikation verhindern Wechsel des globalen Servers %s"
+ geo "Binary-Log-ი და რეპლიკაცია კრძალავს გლობალური სერვერის %s ცვლილებას"
spa "El historial (log) binario y la réplica prohibe cambiar el servidor global %s"
ER_NO_FILE_MAPPING
chi "无法映射文件:%-.200s,错误号码:%M"
eng "Can't map file: %-.200s, errno: %M"
ger "Kann Datei nicht abbilden: %-.200s, Fehler: %M"
+ geo "ფაილის მიბმის შეცდომა %-.200s, შეცდ. კოდი: %M"
spa "No puedo mapear fichero/archivo: %-.200s, error: %M"
ER_WRONG_MAGIC
chi "魔法错误%-.64s"
eng "Wrong magic in %-.64s"
ger "Falsche magische Zahlen in %-.64s"
+ geo "არასწორი მაგიური რიცხვი %-.64s-ში"
spa "Magia equivocada en %-.64s"
ER_PS_MANY_PARAM
chi "Prepared statement包含太多占位符"
eng "Prepared statement contains too many placeholders"
ger "Vorbereitete Anweisung enthält zu viele Platzhalter"
+ geo "მომზდადებული გამოსახულება მეტისმეტად ბევრ ადგილმჭერს შეიცავს"
spa "Sentencia preparada contiene demasiados marcadores de posición"
ER_KEY_PART_0
chi "索引部分'%-.192s'长度不能为0"
eng "Key part '%-.192s' length cannot be 0"
ger "Länge des Schlüsselteils '%-.192s' kann nicht 0 sein"
+ geo "გასაღების ნაწილის '%-.192s' სიგრძე ნულის ტოლი ვერ იქნება"
spa "El tamaño de trozo de clave '%-.192s' no puede ser 0"
ER_VIEW_CHECKSUM
chi "查看文本checksum失败"
eng "View text checksum failed"
ger "View-Text-Prüfsumme fehlgeschlagen"
+ geo "View-Text-ის საკონტროლო ჯამის პრობლემა"
rus "Проверка контрольной суммы текста VIEW провалилась"
spa "Ha fallado la suma de comprobación del texto de la vista"
ukr "Перевірка контрольної суми тексту VIEW не пройшла"
@@ -6025,6 +6416,7 @@ ER_VIEW_MULTIUPDATE
chi "无法通过JOIN视图'%-.192s.%-.192s'修改多个基础表。"
eng "Can not modify more than one base table through a join view '%-.192s.%-.192s'"
ger "Kann nicht mehr als eine Basistabelle über Join-View '%-.192s.%-.192s' ändern"
+ geo "JOIN VIEW '%-.192s.%-.192s'-ით ერთი ან მეტი საბაზისო ცხრილის ცვლილება შეუძლებელია"
rus "Нельзя изменить больше чем одну базовую таблицу используя многотабличный VIEW '%-.192s.%-.192s'"
spa "No puedo modificar más de una tabla base a través de una vista de unión '%-.192s.%-.192s'"
ukr "Неможливо оновити більш ниж одну базову таблицю выкористовуючи VIEW '%-.192s.%-.192s', що містіть декілька таблиць"
@@ -6032,6 +6424,7 @@ ER_VIEW_NO_INSERT_FIELD_LIST
chi "无法写入JOIN视图'%-.192s.%-.192s'没有字段列表"
eng "Can not insert into join view '%-.192s.%-.192s' without fields list"
ger "Kann nicht ohne Feldliste in Join-View '%-.192s.%-.192s' einfügen"
+ geo "join view '%-.192s.%-.192s'-ში ველების სიის გარეშე ჩანაწერეების დამატება შეუძლებელია"
rus "Нельзя вставлять записи в многотабличный VIEW '%-.192s.%-.192s' без списка полей"
spa "No puedo insertar dentro de vista de unión '%-.192s.%-.192s' sin lista de campos"
ukr "Неможливо уставити рядки у VIEW '%-.192s.%-.192s', що містить декілька таблиць, без списку стовбців"
@@ -6039,6 +6432,7 @@ ER_VIEW_DELETE_MERGE_VIEW
chi "无法从JOIN视图'%-.192s.%-.192s'删除"
eng "Can not delete from join view '%-.192s.%-.192s'"
ger "Kann nicht aus Join-View '%-.192s.%-.192s' löschen"
+ geo "JOIN VIEW '%-.192s.%-.192s'-დან წაშლა შეუძლებელია"
rus "Нельзя удалять из многотабличного VIEW '%-.192s.%-.192s'"
spa "No puedo borrar desde vista de unión '%-.192s.%-.192s'"
ukr "Неможливо видалити рядки у VIEW '%-.192s.%-.192s', що містить декілька таблиць"
@@ -6046,133 +6440,159 @@ ER_CANNOT_USER
chi "操作%s失败%.256s"
eng "Operation %s failed for %.256s"
ger "Operation %s schlug fehl für %.256s"
+ geo "%s ოპერაციის შეცდომა %.256s-სთვის"
norwegian-ny "Operation %s failed for '%.256s'"
spa "Ha fallado la operación %s para %.256s"
ER_XAER_NOTA XAE04
chi "XAER_NOTA:未知的XID"
eng "XAER_NOTA: Unknown XID"
ger "XAER_NOTA: Unbekannte XID"
+ geo "XAER_NOTA: უცნობი XID"
spa "XAER_NOTA: XID desconocido"
ER_XAER_INVAL XAE05
chi "XAER_INVAL:无效的参数(或不支持的命令)"
eng "XAER_INVAL: Invalid arguments (or unsupported command)"
ger "XAER_INVAL: Ungültige Argumente (oder nicht unterstützter Befehl)"
+ geo "XAER_INVAL: არასწორი არგუმენტები (ან მხარდაუჭერელი ბრძანება)"
spa "XAER_INVAL: Argumentos inválidos (o comando no soportado)"
ER_XAER_RMFAIL XAE07
chi "XAER_RMFAIL:当全局事务处于%.64s状态时,无法执行该命令"
eng "XAER_RMFAIL: The command cannot be executed when global transaction is in the %.64s state"
ger "XAER_RMFAIL: DEr Befehl kann nicht ausgeführt werden, wenn die globale Transaktion im Zustand %.64s ist"
+ geo "XAER_RMFAIL: ბრძანების შესრულება შეუძლებელია, სანამ გლობალური ტრანზაქცია %.64s მდგომარეობაშია"
rus "XAER_RMFAIL: эту команду нельзя выполнять когда глобальная транзакция находится в состоянии '%.64s'"
spa "XAER_RMFAIL: El comando no se puede ejecutar cuando la transacción global se encuentra en estado %.64s"
ER_XAER_OUTSIDE XAE09
chi "XAER_OUTSIDE:一些工作是在全局交易之外完成的"
eng "XAER_OUTSIDE: Some work is done outside global transaction"
ger "XAER_OUTSIDE: Einige Arbeiten werden außerhalb der globalen Transaktion verrichtet"
+ geo "XAER_OUTSIDE: ზოგიერთი სამუსაო გლობალური ტრანზაქცის გარეთ სრულდება"
spa "XAER_OUTSIDE: Algún trabajo se ha realizado fuera de la transacción global"
ER_XAER_RMERR XAE03
chi "XAER_RMERR:事务分支中发生致命错误 - 检查您的数据以获得一致性"
eng "XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency"
ger "XAER_RMERR: Schwerwiegender Fehler im Transaktionszweig - prüfen Sie Ihre Daten auf Konsistenz"
+ geo "XAER_RMERR: ტრანზაქციის ბრენჩის ფატალური შეცდომა - შეამოწმეთ თქვენი მონაცემების სიმთელე"
spa "XAER_RMERR: Ha ocurrido un error fatal en la rama de la transacción - revise la consitencia de sus datos"
ER_XA_RBROLLBACK XA100
chi "XA_RBROLBACK:交易分支回滚"
eng "XA_RBROLLBACK: Transaction branch was rolled back"
ger "XA_RBROLLBACK: Transaktionszweig wurde zurückgerollt"
+ geo "XA_RBROLLBACK: ტრნზაქციის ბრენჩი დაბრუნდა"
spa "XA_RBROLLBACK: La rama de la transacción ha sido retrocedida (rolled back)"
ER_NONEXISTING_PROC_GRANT 42000
chi "无授权:用户'%-.48s'主机'%-.64s'ROUTINE'%-.192s'"
eng "There is no such grant defined for user '%-.48s' on host '%-.64s' on routine '%-.192s'"
ger "Es gibt diese Berechtigung für Benutzer '%-.48s' auf Host '%-.64s' für Routine '%-.192s' nicht"
+ geo "მომხმარებლისთვის '%-.48s' ჰოსტზე '%-.64s' ქვეპროგრამაზე '%-.192s' უფლება აღწერილი არაა"
spa "No existe tal concesión definida para el usuario '%-.48s' en equipo '%-.64s' en rutina '%-.192s'"
ER_PROC_AUTO_GRANT_FAIL
chi "无法授予EXECUTE和ALTER ROUTINE权限"
eng "Failed to grant EXECUTE and ALTER ROUTINE privileges"
ger "Gewährung von EXECUTE- und ALTER-ROUTINE-Rechten fehlgeschlagen"
+ geo "EXECUTE და ALTER ROUTINE პრივილეგიების მინიჭების შეცდომა"
spa "Fallo al conceder privilegios de EXECUTE y ALTER ROUTINE"
ER_PROC_AUTO_REVOKE_FAIL
chi "无法撤消所有权限以删除例程"
eng "Failed to revoke all privileges to dropped routine"
ger "Rücknahme aller Rechte für die gelöschte Routine fehlgeschlagen"
+ geo "მოცილებული პროცედურიდან ყველა პრივილეგიის გაუქმების შეცდომა"
spa "Fallo al rescindir todos los privilegios de la rutina anulada"
ER_DATA_TOO_LONG 22001
chi "列'%s'行%lu数据太长"
eng "Data too long for column '%s' at row %lu"
ger "Daten zu lang für Feld '%s' in Zeile %lu"
+ geo "მონაცემი ძალიან გრძელია სვეტისთვის '%s' მწკრივზე %lu"
spa "Datos demasiado largos para la columna '%s' en la fila %lu"
ER_SP_BAD_SQLSTATE 42000
chi "坏SQLSTATE:'%s'"
eng "Bad SQLSTATE: '%s'"
ger "Ungültiger SQLSTATE: '%s'"
+ geo "ცუდი SQLSTATE: '%s'"
spa "Mal SQLSTATE: '%s'"
ER_STARTUP
chi "%s:已经准备好接受连接\nVersion:'%s'套接字:'%s'端口:%d %s"
eng "%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d %s"
ger "%s: bereit für Verbindungen.\nVersion: '%s' Socket: '%s' Port: %d %s"
+ geo "%s: დასაკავშირებლად მზადაა.\nვერსია: '%s' სოკეტი: '%s' პორტი: %d %s"
spa "%s: preparada para conexiones.\nVersión: '%s' conector: '%s' puerto: %d %s"
ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR
chi "无法从带有固定大小行的文件中加载值到变量"
eng "Can't load value from file with fixed size rows to variable"
ger "Kann Wert aus Datei mit Zeilen fester Größe nicht in Variable laden"
+ geo "ფიქსირებული ზომის მწკრივების მქონე ფაილიდან ცვლადში მნისვნელობის ჩატვირთვის შეცდომა"
spa "No puedo cargar valor desde fichero/archivo con filas de tamaño fijo en variable"
ER_CANT_CREATE_USER_WITH_GRANT 42000
chi "您不允许使用创建用户时给予GRANT"
eng "You are not allowed to create a user with GRANT"
ger "Sie dürfen keinen Benutzer mit GRANT anlegen"
+ geo "GRANT-ით მომხმარებლის შექმნის უფლება არ გაქვთ"
spa "No está autorizado a crear un usuario con GRANT"
ER_WRONG_VALUE_FOR_TYPE
chi "不正确的%-.32s值:'%-.128T' 函数:%-.32s"
eng "Incorrect %-.32s value: '%-.128T' for function %-.32s"
ger "Falscher %-.32s-Wert: '%-.128T' für Funktion %-.32s"
+ geo "არასწორი %-.32s მნიშვნელობა: '%-.128T' ფუნქციისთვის %-.32s"
spa "Incorrecto valor %-.32s: '%-.128T' para la función %-.32s"
ER_TABLE_DEF_CHANGED
chi "表定义已更改,请重试"
eng "Table definition has changed, please retry transaction"
ger "Tabellendefinition wurde geändert, bitte starten Sie die Transaktion neu"
+ geo "ცხრილის აღწერა შეიცვალა. გთხოვთ, თავიდან გაუშვათ ტრანზაქცია"
spa "Ha cambiado la definición de la tabla, por favor reintente la transacción"
ER_SP_DUP_HANDLER 42000
chi "在同一块中声明的处理程序重复"
eng "Duplicate handler declared in the same block"
ger "Doppelter Handler im selben Block deklariert"
+ geo "იგივე ბლოკში დუბლირებული დამმუშავებელია აღწერილი"
spa "Manejador duplicado declarado en mismo bloque"
ER_SP_NOT_VAR_ARG 42000
chi "OUT或INOUT参数%d 例程 %s的不是BEFORE触发器里的变量或新伪变量"
eng "OUT or INOUT argument %d for routine %s is not a variable or NEW pseudo-variable in BEFORE trigger"
ger "OUT- oder INOUT-Argument %d für Routine %s ist keine Variable"
+ geo "OUT და INOUT არგუმენტი %d ქვეპროგრამისთვის %s ცვლადს არ წარმოადგენს, ან NEW ფსევდოცვლადი BEFORE ტრიგერში"
spa "El argumento %d OUT o INOUT para la rutina %s no es una variable o pseudo-variable NEW en disparador BEFORE"
ER_SP_NO_RETSET 0A000
chi "不允许从%s返回结果集"
eng "Not allowed to return a result set from a %s"
ger "Rückgabe einer Ergebnismenge aus einer %s ist nicht erlaubt"
+ geo "%s-დან შედეგების ნაკრების დაბრუნება დაუშვებელია"
spa "No autorizado a devolver un conjunto de resultados desde un %s"
ER_CANT_CREATE_GEOMETRY_OBJECT 22003
chi "无法从发送到几何字段的数据中获取几何对象"
eng "Cannot get geometry object from data you send to the GEOMETRY field"
ger "Kann kein Geometrieobjekt aus den Daten machen, die Sie dem GEOMETRY-Feld übergeben haben"
+ geo "GEOMETRY ველში გაგზავნილი მონაცემებიდან გეომეტრიული ობიექტის მიღება შეუძლებელია"
spa "No puedo obtener objeto de geometría desde los datos que vd envía al campo GEOMETRY"
ER_FAILED_ROUTINE_BREAK_BINLOG
chi "ROUTINE失败,定义中既没有NO SQL也没有READ SQL DAT。启用二进制日志记录;如果更新非事务性表,则二进制日志将会错过其更改"
eng "A routine failed and has neither NO SQL nor READS SQL DATA in its declaration and binary logging is enabled; if non-transactional tables were updated, the binary log will miss their changes"
ger "Eine Routine, die weder NO SQL noch READS SQL DATA in der Deklaration hat, schlug fehl und Binärlogging ist aktiv. Wenn Nicht-Transaktions-Tabellen aktualisiert wurden, enthält das Binärlog ihre Änderungen nicht"
+ geo "ქვეპროგრამა ავარიულად დასრულდა და გააჩნია არც NO SQL, არც READS SQL DATA მის აღწერაში და ბინარული ჟურნალი ჩართულია. თუ განახლებულია არატრანზაქციული ცხრილები, ბინარული ჟურნალი მათ ცვლილებებს არ შეიცავს"
spa "Ha fallado una rutina y no tiene ni NO SQL ni READS SQL DATA en su declaración y el historial (log) binario se encuentra activado; si han sido actualizadas tablas no transaccionales, el fichero/archivo binario de historial (log) perderá sus cambios"
ER_BINLOG_UNSAFE_ROUTINE
chi "此函数定义中没有DETERMINISTIC,NO SQL,或者READS SQL DATA,并且已启用二进制日志记录(您*可能*希望使用较少的安全性的log_bin_trust_function_creators变量)"
eng "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)"
ger "Diese Routine hat weder DETERMINISTIC, NO SQL noch READS SQL DATA in der Deklaration und Binärlogging ist aktiv (*vielleicht* sollten Sie die weniger sichere Variable log_bin_trust_function_creators verwenden)"
+ geo "ამ ფუნქციას არ გააჩნია DETERMINISTIC, NO SQL, ან READS SQL DATA მის აღწერაში და ბინარული ჟურნალი ჩართულია (შეიძლება თქვენ ნაკლებად უსაფრთხო log_bin_trust_function_creators ცვლადის გამოყენება გჭირდებათ)"
spa "Esta función no tiene ninguno de DETERMINISTIC, NO SQL o READS SQL DATA en su declaración y está activado el historial binario (vd *podría* querer usar la variable menos segura log_bin_trust_function_creators)"
ER_BINLOG_CREATE_ROUTINE_NEED_SUPER
chi "您没有超级特权和二进制日志记录已启用(您*可能*想要使用较少的安全log_bin_trust_function_creators变量)"
eng "You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)"
ger "Sie haben keine SUPER-Berechtigung und Binärlogging ist aktiv (*vielleicht* sollten Sie die weniger sichere Variable log_bin_trust_function_creators verwenden)"
+ geo "თქვენ SUPER პრივილეგია არ გაგაჩნიათ და ბინარული ჟურნალი ჩართულია (შეიძლება თქვენ ნაკლებად უსაფრთხო log_bin_trust_function_creators ცვლადის გამოყენება გჭირდებათ)"
spa "No tiene el privilegio SUPER y está activado el historial binario (*podría* querer usar la variable menos segura log_bin_trust_function_creators)"
ER_EXEC_STMT_WITH_OPEN_CURSOR
chi "您无法执行具有与之关联的打开Cursor的prepared statement。重置语句以重新执行它"
eng "You can't execute a prepared statement which has an open cursor associated with it. Reset the statement to re-execute it"
ger "Sie können keine vorbereitete Anweisung ausführen, die mit einem geöffneten Cursor verknüpft ist. Setzen Sie die Anweisung zurück, um sie neu auszuführen"
+ geo "თქვენ არ შეგიძლიათ გაუშვათ მომზადებული გამოსახულება, რომელსაც მასთან ასოცირებული ღია კურსორი გააჩნია. გამოსახულების თავიდან შესასრულებლად მისი საწყის მნიშვნელობებზე დაბრუნებაა საჭირო"
spa "No puede ejecutar una sentencia preparada que tiene abierto un cursor asociado con ella. Renueve la sentencia para re-ejecutarla"
ER_STMT_HAS_NO_OPEN_CURSOR
chi "语句(%lu)没有开放的Cursor"
eng "The statement (%lu) has no open cursor"
ger "Die Anweisung (%lu) hat keinen geöffneten Cursor"
+ geo "გამოსახულებას (%lu) ღია კურსორი არ გააჩნია"
spa "La sentencia (%lu) no tiene cursor abierto"
ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
chi "在存储的函数或触发器中不允许显式或隐式提交"
@@ -6183,46 +6603,55 @@ ER_NO_DEFAULT_FOR_VIEW_FIELD
chi "VIEW的列'%-.192s.%-.192s'底层表没有默认值"
eng "Field of view '%-.192s.%-.192s' underlying table doesn't have a default value"
ger "Ein Feld der dem View '%-.192s.%-.192s' zugrundeliegenden Tabelle hat keinen Vorgabewert"
+ geo "ხედის ველის '%-.192s.%-.192s' ქვედა ცხრილს ნაგულისხმები მნიშვნელობა არ გააჩნია"
spa "El campo de tabla subyacente de vista '%-.192s.%-.192s' no tiene valor por defecto"
ER_SP_NO_RECURSION
chi "不允许递归存储功能和触发器"
eng "Recursive stored functions and triggers are not allowed"
ger "Rekursive gespeicherte Routinen und Triggers sind nicht erlaubt"
+ geo "რეკურსიული დამახსოვრებული ფუნქციები და ტრიგერები დაშვებული არაა"
spa "No autorizadas funciones almacenadas recursivas ni disparadores"
ER_TOO_BIG_SCALE 42000 S1009
chi "指定的大规模为'%-.192s'。最大是%u"
eng "Too big scale specified for '%-.192s'. Maximum is %u"
ger "Zu großer Skalierungsfaktor für '%-.192s' angegeben. Maximum ist %u"
+ geo "'%-.192s'-სთვის მითითებული მასშტაბი მეტისმეტად დიდია. მაქსიმუმია %u"
spa "Escala demasiado grande especificada para '%-.192s'. El máximo es de %u"
ER_TOO_BIG_PRECISION 42000 S1009
chi "指定的精度太大 '%-.192s'。最大是%u"
eng "Too big precision specified for '%-.192s'. Maximum is %u"
ger "Zu große Genauigkeit für '%-.192s' angegeben. Maximum ist %u"
+ geo "'%-.192s'-სთვის მითითებული სიზუსთე მეტისმეტად დიდია. მაქსიმუმია %u"
spa "Precisión demasiado grande especificada para '%-.192s'. El máximo es de %u"
ER_M_BIGGER_THAN_D 42000 S1009
chi "对于FLOAT(M,D),DOUBLE(M,D)或DECIMAL(M,D),M必须> = D(列'%-.192s')"
eng "For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '%-.192s')"
ger "Für FLOAT(M,D), DOUBLE(M,D) oder DECIMAL(M,D) muss M >= D sein (Feld '%-.192s')"
+ geo "float(M,D), double(M,D) და decimal(M,D)-სთვის M >= D უნდა იყოს (სვეტი '%-.192s')"
spa "Para flotante(M,D), doble(M,D) o decimal(M,D), M debe de ser >= D (columna '%-.192s')"
ER_WRONG_LOCK_OF_SYSTEM_TABLE
chi "您无法将系统表的写入锁定与其他表或锁定类型相结合"
eng "You can't combine write-locking of system tables with other tables or lock types"
ger "Sie können Schreibsperren auf der Systemtabelle nicht mit anderen Tabellen kombinieren"
+ geo "სისტემური ცხრილების ჩაწერის დაბლოკვის სხვა ცხრილების ან დაბლოკვის ტიპებთან შერევა შეუძლებელია"
spa "No puede combinar bloqueo de escritura de tablas de sistema con otras tablas o tipos de bloqueo"
ER_CONNECT_TO_FOREIGN_DATA_SOURCE
chi "无法连接到外数据源:%.64s"
eng "Unable to connect to foreign data source: %.64s"
ger "Kann nicht mit Fremddatenquelle verbinden: %.64s"
+ geo "გარე მონაცემების წყაროსთან მიერთების შეცდომა: %.64s"
spa "No puedo conectar a fuente foránea de datos: %.64s"
ER_QUERY_ON_FOREIGN_DATA_SOURCE
chi "处理对外数据源上的查询时出现问题。数据源错误:%-.64s"
eng "There was a problem processing the query on the foreign data source. Data source error: %-.64s"
ger "Bei der Verarbeitung der Abfrage ist in der Fremddatenquelle ein Problem aufgetreten. Datenquellenfehlermeldung: %-.64s"
+ geo "გარე მონაცემების წყაროზე მოთხოვნის დამუშავების პრობლემა. მონაცემების წყაროს შეცდომა: %-.64s"
spa "Hubo un problema procesando la consulta (query) en la fuente foránea de datos. Error de fuente de datos: %-.64s"
ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST
chi "您尝试引用的外数据源不存在。数据源错误:%-.64s"
eng "The foreign data source you are trying to reference does not exist. Data source error: %-.64s"
ger "Die Fremddatenquelle, auf die Sie zugreifen wollen, existiert nicht. Datenquellenfehlermeldung: %-.64s"
+ geo "მონაცემების გარე წყარო, რომელსაც ცდილობთ მიმართოთ, არ არსებობს. მონაცემების წყაროს შეცდომა: %-.64s"
spa "La fuente foránea de datos que intenta referenciar no existe. Error en fuente de datos: %-.64s"
ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE
chi "无法创建联合表。数据源连接字符串'%-.64s'不是正确的格式"
@@ -6243,66 +6672,79 @@ ER_TRG_IN_WRONG_SCHEMA
chi "触发在错的SCHEMA"
eng "Trigger in wrong schema"
ger "Trigger im falschen Schema"
+ geo "ტრიგერი არასწორ სქემაშია"
spa "Disparador en esquema equivocado"
ER_STACK_OVERRUN_NEED_MORE
chi "线程堆栈溢出:%ld字节堆栈的%ld字节,以及所需的%ld字节。使用'mariadbd --thread_stack =#'指定更大的堆栈"
eng "Thread stack overrun: %ld bytes used of a %ld byte stack, and %ld bytes needed. Consider increasing the thread_stack system variable."
ger "Thread-Stack-Überlauf: %ld Bytes eines %ld-Byte-Stacks in Verwendung, und %ld Bytes benötigt. Verwenden Sie 'mariadbd --thread_stack=#', um einen größeren Stack anzugeben"
+ geo "ნაკადის სტეკის გადავსება: გამოყენებულია %ld ბაიტი %ld ბაიტიანი სტეკიდან და საჭიროა %ld ბაიტი. გაზარდეთ სისტემის ცვლადი thread_stack."
jpn "スレッドスタック不足です(使用: %ld ; サイズ: %ld ; 要求: %ld)。より大きい値で 'mariadbd --thread_stack=#' の指定をしてください。"
spa "Desbordamiento en pila de hilos (threads): %ld bytes usados de una pila de %ld y son necesarios %ld bytes. Considere el incrementar la variable de sistema --thread_stack=#."
ER_TOO_LONG_BODY 42000 S1009
chi "'%-.100s”的ROUTINE太长了"
eng "Routine body for '%-.100s' is too long"
ger "Routinen-Body für '%-.100s' ist zu lang"
+ geo "qveprogramis სხეული '%-.100s' ძალიან დიდია"
spa "El cuerpo de rutina para '%-.100s' es demasiado largo"
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
chi "无法删除默认索引缓存"
eng "Cannot drop default keycache"
ger "Der vorgabemäßige Schlüssel-Cache kann nicht gelöscht werden"
+ geo "ნაგულისხმები გასაღების კეშის წაშლა შეუძლებელია"
spa "No puedo eliminar keycache por defecto"
ER_TOO_BIG_DISPLAYWIDTH 42000 S1009
chi "显示宽度超过'%-.192s'的范围(max =%lu)"
eng "Display width out of range for '%-.192s' (max = %lu)"
ger "Anzeigebreite außerhalb des zulässigen Bereichs für '%-.192s' (Maximum = %lu)"
+ geo "'%-.192s'-ის ჩვენების სიგანე დიაპაზონს გარეთაა (მაქს. = %lu)"
spa "Ancho a mostrar fuera de rango para '%-.192s' (máx = %lu)"
ER_XAER_DUPID XAE08
chi "XAER_DUPID:xid已存在"
eng "XAER_DUPID: The XID already exists"
ger "XAER_DUPID: Die XID existiert bereits"
+ geo "XAER_DUPID: XID-ი უკვე არსებობს"
spa "XAER_DUPID: El XID ya existe"
ER_DATETIME_FUNCTION_OVERFLOW 22008
chi "DateTime函数:%-.32s字段溢出"
eng "Datetime function: %-.32s field overflow"
ger "Datetime-Funktion: %-.32s Feldüberlauf"
+ geo "დრო-თარიღის ფუნქცია: %-.32s ველი გადავსებულია"
spa "Función Datetime: %-.32s desbordamiento de campo"
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
chi "在存储的函数/触发器中无法更新表'%-.192s',因为它已被调用此存储的函数/触发器调用的语句"
eng "Can't update table '%-.192s' in stored function/trigger because it is already used by statement which invoked this stored function/trigger"
ger "Kann Tabelle '%-.192s' in gespeicherter Funktion oder Trigger nicht aktualisieren, weil sie bereits von der Anweisung verwendet wird, die diese gespeicherte Funktion oder den Trigger aufrief"
+ geo "ცხრილის ('%-.192s') შენახულ პროცედურაში/ტრიგერში განახლება შეუძლებელია, რადგან ის უკვე გამოიყენება გამოსახულების მიერ, რომელსაც ეს შენახული ფუნქცია/ტრიგერი იყენებს"
spa "No puedo actualizar tabla '%-.192s' en función almacenada/disparador porque ya está siendo usada por la sentencia que invocó esta función almacenada/disparador"
ER_VIEW_PREVENT_UPDATE
chi "表'%-.192s'的定义可防止在表'%-.192s'上的操作'%-.192s'"
eng "The definition of table '%-.192s' prevents operation %-.192s on table '%-.192s'"
ger "Die Definition der Tabelle '%-.192s' verhindert die Operation %-.192s auf Tabelle '%-.192s'"
+ geo "ცხრილის ('%-.192s') აღწერა ხელს უშლის ოპერაციას ('%-.192s') ცხრილზე '%-.192s'"
spa "La definición de la tabla '%-.192s' previene la operación %-.192s en la tabla '%-.192s'"
ER_PS_NO_RECURSION
chi "prepared statement包含一个有关该语句的存储例程调用。它不允许以这种递归方式执行prepared statement"
eng "The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner"
ger "Die vorbereitete Anweisung enthält einen Aufruf einer gespeicherten Routine, die auf eben dieselbe Anweisung verweist. Es ist nicht erlaubt, eine vorbereitete Anweisung in solch rekursiver Weise auszuführen"
+ geo "მომზადებული გამოსახულება შეიცავს დამახსოვრებულ ქვეპროგრამის გამოძახებას, რომელიც იგივე გამოსახულებას მიმართავს. შენახული გამოსახულების რეკურსიულად გაშვება დაშვებული არაა"
spa "La sentencia preparada contiene una llamada a rutina almacenada que se refiere a esa misma sentencia. No está permitido ejecutar una sentencia preparada de esta manera recursiva"
ER_SP_CANT_SET_AUTOCOMMIT
chi "不允许从存储的函数或触发器设置自动判处"
eng "Not allowed to set autocommit from a stored function or trigger"
ger "Es ist nicht erlaubt, innerhalb einer gespeicherten Funktion oder eines Triggers AUTOCOMMIT zu setzen"
+ geo "შენახული ფუნქციიდან და ტრიგერიდან ავტოკომიტის დაყენება დაშვებული არაა"
spa "No permitido usar auto acometida (autocommit) desde una función almacenada o disparador"
ER_MALFORMED_DEFINER 0L000
chi "无效的定义"
eng "Invalid definer"
+ geo "არასწორი აღმწერი"
spa "Definidor inválido"
ER_VIEW_FRM_NO_USER
chi "VIEW'%-.192s'。'%-.192s'没有绝定的信息(旧表格式)。当前用户用作定义。请重新创建视图!"
eng "View '%-.192s'.'%-.192s' has no definer information (old table format). Current user is used as definer. Please recreate the view!"
ger "View '%-.192s'.'%-.192s' hat keine Definierer-Information (altes Tabellenformat). Der aktuelle Benutzer wird als Definierer verwendet. Bitte erstellen Sie den View neu"
+ geo "ხედს '%-.192s'.'%-.192s' აღმწერის ინფორმაცია არ გააჩნია (ცხრილის ფორმატი ძველია). აღმწერად მიმდინარე მომხმარებელი გამოიყენება. გთხოვთ, შექმენით ეს ხედი თავიდან!"
spa "La vista '%-.192s'.'%-.192s' no tiene información de definidor (formato viejo de tabla). Se usa el usuario actual como definidor. Por favor, ¡recrea la vista!"
ER_UNUSED_30
eng "You should never see it"
@@ -6310,141 +6752,168 @@ ER_NO_SUCH_USER
chi "指定为定义的用户('%-.64s'@'%-.64s')不存在"
eng "The user specified as a definer ('%-.64s'@'%-.64s') does not exist"
ger "Der als Definierer angegebene Benutzer ('%-.64s'@'%-.64s') existiert nicht"
+ geo "('%-.64s'@'%-.64s')-ის აღმწერად მითითებული მომხმარებელი არ არსებობს"
spa "El usuario especificado como definidor ('%-.64s'@'%-.64s') no existe"
ER_FORBID_SCHEMA_CHANGE
chi "不允许从'%-.192s'到'%-.192s'的SCHEMA更改"
eng "Changing schema from '%-.192s' to '%-.192s' is not allowed"
ger "Wechsel des Schemas von '%-.192s' auf '%-.192s' ist nicht erlaubt"
+ geo "სქემის '%-.192s'-დან '%-.192s'-ზე შეცვლა დაშვებული არაა"
spa "Vd no está autorizado a cambiar el esquema de '%-.192s' a '%-.192s'"
ER_ROW_IS_REFERENCED_2 23000
chi "无法删除或更新父行:外键约束失败(%.192s)"
eng "Cannot delete or update a parent row: a foreign key constraint fails (%.192s)"
ger "Kann Eltern-Zeile nicht löschen oder aktualisieren: eine Fremdschlüsselbedingung schlägt fehl (%.192s)"
+ geo "მშობელი მწკრივის წაშლა ან განახლება შეუძლებელია: გარე გასაღების შეზღუდვა შეცდომას შეიცავს (%.192s)"
spa "No puedo borrar o actualizar una fila padre: falla una restricción de clave foránea (%.192s)"
ER_NO_REFERENCED_ROW_2 23000
chi "无法添加或更新子行:外键约束失败(%.192s)"
eng "Cannot add or update a child row: a foreign key constraint fails (%.192s)"
ger "Kann Kind-Zeile nicht hinzufügen oder aktualisieren: eine Fremdschlüsselbedingung schlägt fehl (%.192s)"
+ geo "შვილი მწკრივის წაშლა ან განახლება შეუძლებელია: გარე გასაღების შეზღუდვა შეცდომას შეიცავს (%.192s)"
spa "No puedo añadir o actualizar una fila hija: falla una restricción de clave foránea (%.192s)"
ER_SP_BAD_VAR_SHADOW 42000
chi "变量'%-.64s'必须用`...`,或重命名"
eng "Variable '%-.64s' must be quoted with `...`, or renamed"
ger "Variable '%-.64s' muss mit `...` geschützt oder aber umbenannt werden"
+ geo "ცვლადი '%-.64s' `...` ბრჭყალებში უნდა ჩასვათ, ან სახელი გადაარქვათ"
spa "La variable '%-.64s' debe de ser entrecomillada con `...` o renombrada"
ER_TRG_NO_DEFINER
chi "触发'%-.192s'的绝对属性。'%-.192s'。触发器将在调用者的授权下激活,该权限可能不足。请重新创建触发器"
eng "No definer attribute for trigger '%-.192s'.'%-.192s'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger"
ger "Kein Definierer-Attribut für Trigger '%-.192s'.'%-.192s'. Der Trigger wird mit der Autorisierung des Aufrufers aktiviert, der möglicherweise keine zureichenden Berechtigungen hat. Bitte legen Sie den Trigger neu an"
+ geo "ტრიგერს '%-.192s'.'%-.192s' აღმწერის ატრიბუტი არ გააჩნია. ტრიგერი გამშვების ავტორიზაციის ქვეშ გაეშვება, რომლის პრივილეგიებიც შეიძლება საკმარისი არ აღმოჩნდეს. თავიდან შექმენით ტრიგერი"
spa "No hay atributo de definidor para disparador '%-.192s'.'%-.192s'. El disparador será activado bajo la autorización del invocador, el cual puede tener insuficientes privilegios. Por favor, vuelva a crear el disparador"
ER_OLD_FILE_FORMAT
chi "'%-.192s'具有旧格式,您应该重新创建'%s'对象"
eng "'%-.192s' has an old format, you should re-create the '%s' object(s)"
ger "'%-.192s' hat altes Format, Sie sollten die '%s'-Objekt(e) neu erzeugen"
+ geo "'%-.192s'-ის ფორმატი მოძველებულია. საჭიროა '%s' ობიექტის თავიდან შექმნა"
spa "'%-.192s' tiene un formato viejo, debería vd de volver a crear el/los objeto(s) '%s'"
ER_SP_RECURSION_LIMIT
chi "递归限制%d(如max_sp_recursion_depth变量设置)的例程%.192s"
eng "Recursive limit %d (as set by the max_sp_recursion_depth variable) was exceeded for routine %.192s"
ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde für Routine %.192s überschritten"
+ geo "რეკურსიულობის ლიმიტი %d (დაყენებულია ცვლადით max_sp_recursion_depth) გადაცილებულია ქვეპროგრამისთვის %.192s"
spa "El límite recursivo %d (según se indica mediante la variable max_sp_recursion_depth) se ha excedido para la rutina %.192s"
ER_SP_PROC_TABLE_CORRUPT
chi "无法加载常规%-.192s(内部代码%d)。有关更多详细信息,请运行SHOW WARNINGS"
eng "Failed to load routine %-.192s (internal code %d). For more details, run SHOW WARNINGS"
ger "Routine %-.192s (interner Code %d) konnte nicht geladen werden. Weitere Einzelheiten erhalten Sie, wenn Sie SHOW WARNINGS ausführen"
+ geo "ქვეპროგრამის (%-.192s) ჩატვირთვის შეცდომა (შიდა კოდი %d). მეტი დეტალებისთვის გაუშვით SHOW WARNINGS"
ukr "Невдала спроба завантажити процедуру %-.192s (внутрішний код %d). Для отримання детальної інформації використовуйте SHOW WARNINGS"
spa "No pude cargar la rutina %-.192s (código interno %d). Para más detalles, ejecute SHOW WARNINGS"
ER_SP_WRONG_NAME 42000
chi "常规名称错误不正确'%-.192s'"
eng "Incorrect routine name '%-.192s'"
ger "Ungültiger Routinenname '%-.192s'"
+ geo "ქვეპროგრამის არასწორი სახელი '%-.192s'"
spa "Nombre incorrecto de rutina '%-.192s'"
ER_TABLE_NEEDS_UPGRADE
chi "需要升级。请做\"修复%s%`s \"或转储/重新加载以修复!"
eng "Upgrade required. Please do \"REPAIR %s %`s\" or dump/reload to fix it!"
ger "Aktualisierung erforderlich. Bitte zum Reparieren \"REPAIR %s %`s\" eingeben!"
+ geo "აუცილებელია განახლება. გასასწორებლად გაუშვით \"REPAIR %s %`s\" ან დამპი აიღეთ და თავიდან ჩატვირთეთ!"
spa "Es necesaria una mejora. Por favor, ¡haga \"REPAIR %s %`s\" o vuelque/recargue para arreglarlo!"
ER_SP_NO_AGGREGATE 42000
chi "存储函数不支持聚合"
eng "AGGREGATE is not supported for stored functions"
ger "AGGREGATE wird bei gespeicherten Funktionen nicht unterstützt"
+ geo "დამახსოვრებული ფუნქციებისთვის AGGREGATE მხარდაჭერილი არაა"
spa "AGGREGATE no está soportado en funciones almacenadas"
ER_MAX_PREPARED_STMT_COUNT_REACHED 42000
chi "无法创建超过max_prepared_stmt_count语句(当前值:%u)"
eng "Can't create more than max_prepared_stmt_count statements (current value: %u)"
ger "Kann nicht mehr Anweisungen als max_prepared_stmt_count erzeugen (aktueller Wert: %u)"
+ geo "max_prepared_stmt_count-ზე მეტი გამოსახულების შექმნა შეუძლებელია (მიმდინარე მნიშვნელობაა: %u)"
spa "No puedo crear más de max_prepared_stmt_count sentencias (valor en curso: %u)"
ER_VIEW_RECURSIVE
chi "%`s.%`s包含视图递归"
eng "%`s.%`s contains view recursion"
ger "%`s.%`s enthält View-Rekursion"
+ geo "%`s.%`s ხედის რეკურსიას შეიცავს"
spa "`%-.192s`.`%-.192s` contiene recursividad de vista""
ER_NON_GROUPING_FIELD_USED 42000
chi "非分组字段'%-.192s'用于%-.64s条款"
eng "Non-grouping field '%-.192s' is used in %-.64s clause"
ger "In der %-.192s-Klausel wird das die Nicht-Gruppierungsspalte '%-.64s' verwendet"
+ geo "არა-დაჯგუფებადი ველი '%-.192s' გამოიყენება პირობაში %-.64s"
spa "No hay campo agrupado '%-.192s' usado en cláusula %-.64s"
ER_TABLE_CANT_HANDLE_SPKEYS
chi "存储引擎%s不支持SPATIAL索引"
eng "The storage engine %s doesn't support SPATIAL indexes"
ger "Der verwendete Tabellentyp (%s) unterstützt keine SPATIAL-Indizes"
+ geo "საცავის ძრავას "%s" SPATIAL ტიპის ინდექსების მხარდაჭერა არ გააჩნია"
spa "El motor de almacenaje %s no soporta índices SPATIAL"
ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA
chi "无法在系统表上创建触发器"
eng "Triggers can not be created on system tables"
ger "Trigger können nicht auf Systemtabellen erzeugt werden"
+ geo "სისტემურ ცხრილებზე ტრიგერებს ვერ შექმნით"
spa "Los disparadores no pueden ser creados en las tablas del sistema"
ER_REMOVED_SPACES
chi "前面的空格从名称'%s'删除"
eng "Leading spaces are removed from name '%s'"
ger "Führende Leerzeichen werden aus dem Namen '%s' entfernt"
+ geo "დასაწყისში გამოტოვებები წაშლილია სახელიდა '%s'"
spa "Se quitan los espacios iniciales del nombre '%s'"
ER_AUTOINC_READ_FAILED
chi "无法从存储引擎读取自动增量值"
eng "Failed to read auto-increment value from storage engine"
ger "Lesen des Autoincrement-Werts von der Speicher-Engine fehlgeschlagen"
+ geo "საცავის ძრავიდან ავტომატური გაზრდის მნიშვნელობის წაკითხვის შეცდომა"
hindi "स्टोरेज इंजन से auto-increment का मान पढ़ने में असफल रहे"
spa "No pude leer valor de auto-incremento del motor de almacenaje"
ER_USERNAME
chi "用户名"
eng "user name"
ger "Benutzername"
+ geo "მომხმარებლის სახელი"
hindi "यूज़र का नाम"
spa "nombre de usuario"
ER_HOSTNAME
chi "主机名"
eng "host name"
ger "Hostname"
+ geo "ჰოსტის სახელი"
hindi "होस्ट का नाम"
spa "nombre de equipo"
ER_WRONG_STRING_LENGTH
chi "字符串'%-.70T'对于%s(应不超过%d)太长"
eng "String '%-.70T' is too long for %s (should be no longer than %d)"
ger "String '%-.70T' ist zu lang für %s (sollte nicht länger sein als %d)"
+ geo "სტრიქონი '%-.70T' %s-სთვის ძალიან გრძელია (სიგრძე %d-ზე მეტს არ უნდა უდრიდეს)"
spa "La cadena '%-.70T' es demasiado larga para %s (no debería de ser mayor de %d)"
ER_NON_INSERTABLE_TABLE
chi "目标表%-.100s %s不可插入"
eng "The target table %-.100s of the %s is not insertable-into"
ger "Die Zieltabelle %-.100s von %s ist nicht einfügbar"
+ geo "სამიზნე ცხრილი %-.100s %s-დან ჩამატებადი არაა"
jpn "対象表 %-.100s は挿入可能ではないので、%s を行えません。"
spa "La tabla destino %-.100s de la %s no es insertable-dentro"
ER_ADMIN_WRONG_MRG_TABLE
chi "表'%-.64s'不同定义、或非myisam类型、或不存在"
eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"
ger "Tabelle '%-.64s' ist unterschiedlich definiert, nicht vom Typ MyISAM oder existiert nicht"
+ geo "ცხრილი '%-.64s' სხვანაირადაა აღწერილი, არაა MyISAM-ის ტიპის, ან არ არსებობს"
spa "La tabla '%-.64s' está definida de forma diferente o es del tipo no-MyISAM o no existe"
ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
chi "太高的嵌套SELECT"
eng "Too high level of nesting for select"
ger "Zu tief verschachtelte SELECT-Anweisungen"
+ geo "SELECT-ის მეტისმეტად მაღალი ან ჩალაგების დონე"
spa "Demasiado alto el nivel de anidamiento para la selección"
ER_NAME_BECOMES_EMPTY
chi "名'%-.64s'已成为''"
eng "Name '%-.64s' has become ''"
ger "Name '%-.64s' wurde zu ''"
+ geo "სახელი '%-.64s' გადაიქცა ''"
spa "El nombre '%-.64s' ha pasado a ser ''"
ER_AMBIGUOUS_FIELD_TERM
chi "FIELDS TERMINATED字符串的第一个字符是模棱两可的;请使用非空字段FIELDS ENCLOSED BY"
eng "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY"
ger "Das erste Zeichen der Zeichenkette FIELDS TERMINATED ist mehrdeutig; bitte benutzen Sie nicht optionale und nicht leere FIELDS ENCLOSED BY"
+ geo "FIELDS TERMINATED სტრქოინის პირველი სიმბოლო ბუნდოვანია. გამოიყენეთ სავალდებულო და არაცარიელი FIELDS ENCLOSED BY"
spa "El primer carácter de la cadena de los FIELDS TERMINATED es ambiguo; por favor, use FIELDS ENCLOSED BY no opcionales y no vacíos"
ER_FOREIGN_SERVER_EXISTS
chi "无法创建外部服务器'%s',因为它已经存在"
@@ -6452,6 +6921,7 @@ ER_FOREIGN_SERVER_EXISTS
fin "Vieraata palvelinta '%s' ei voida luoda, koska se on jo olemassa"
fre "Impossible de créer le serveur étranger '%s' car il existe déjà"
ger "Der auswärtige Server '%s' kann nicht erstellt werden, da er bereits vorhanden ist"
+ geo "გარე სერვერის '%s' შექმნა შეუძლებელია. ის უკვე არსებობს"
greek "Δεν είναι δυνατή η δημιουργία ξένου διακομιστή '%s' επειδή υπάρχει ήδη"
ita "Impossibile creare il server esterno '%s' poiché esiste già"
jpn "外部サーバー '%s'は既に存在するため、作成できません"
@@ -6466,136 +6936,159 @@ ER_FOREIGN_SERVER_DOESNT_EXIST
chi "您尝试引用的外部服务器名称不存在。数据源错误:%-.64s"
eng "The foreign server name you are trying to reference does not exist. Data source error: %-.64s"
ger "Die externe Verbindung, auf die Sie zugreifen wollen, existiert nicht. Datenquellenfehlermeldung: %-.64s"
+ geo "გარე სერვერის სახელი, რომელსაც ცდილობთ, მიმართოთ, არ არსებობს. მონაცემების წყაროს შეცდომა: %-.64s"
spa "El nombre del servidor foráneo que intenta referenciar no existe. Error en fuentes de datos: %-.64s"
ER_ILLEGAL_HA_CREATE_OPTION
chi "表存储引擎'%-.64s'不支持创建选项'%.64s'"
eng "Table storage engine '%-.64s' does not support the create option '%.64s'"
ger "Speicher-Engine '%-.64s' der Tabelle unterstützt die Option '%.64s' nicht"
+ geo "ცხრილის საცავის ძრავა '%-.64s' შექმნის პარამეტრის '%-.64s' მხარდაჭერა არ გააჩნია"
spa "El motor de almacenaje de la tabla '%-.64s' no soporta la opción de creación '%.64s'"
ER_PARTITION_REQUIRES_VALUES_ERROR
chi "语法错误:%-.64s PARTITIONING需要定义给每个分区VALUES %-.64s"
eng "Syntax error: %-.64s PARTITIONING requires definition of VALUES %-.64s for each partition"
ger "Fehler in der SQL-Syntax: %-.64s-PARTITIONierung erfordert Definition von VALUES %-.64s für jede Partition"
+ geo "სინტაქსის შეცდომა: %-.64s. PARTITIONING-ს VALUES %-.64s-ის დაყენება სჭირდება თითოეული დანაყოფისთვის"
spa "Error de sintaxis: %-.64s PARTITIONING requiere de la definición de VALUES %-.64s para cada partición"
swe "Syntaxfel: %-.64s PARTITIONering kräver definition av VALUES %-.64s för varje partition"
ER_PARTITION_WRONG_VALUES_ERROR
chi "只有%-.64s PARTITIONING可以使用VALUES %-.64s在分区定义中"
eng "Only %-.64s PARTITIONING can use VALUES %-.64s in partition definition"
ger "Nur %-.64s-PARTITIONierung kann VALUES %-.64s in der Partitionsdefinition verwenden"
+ geo "მხოლოდ %-.64s PARTITIONING-ს შეუძლია გამოიყენოს VALUES %-.64s დანაყოფის აღწერისას"
spa "Sólo %-.64s PARTITIONING puede usar VALUES %-.64s en la definición de la partición"
swe "Endast %-.64s partitionering kan använda VALUES %-.64s i definition av partitionen"
ER_PARTITION_MAXVALUE_ERROR
chi "MAXVALUE只能在最后一个分区定义中使用"
eng "MAXVALUE can only be used in last partition definition"
ger "MAXVALUE kann nur für die Definition der letzten Partition verwendet werden"
+ geo "MAXVALUE-ის გამოყენება მხოლოდ ბოლო დანაყოფის აღწერისას შეგიძლიათ"
spa "MAXVALUE sólo se puede usar en la definición de la última partición"
swe "MAXVALUE kan bara användas i definitionen av den sista partitionen"
ER_PARTITION_SUBPARTITION_ERROR
chi "子分区只能是哈希分区和分区列"
eng "Subpartitions can only be hash partitions and by key"
ger "Unterpartitionen dürfen nur HASH- oder KEY-Partitionen sein"
+ geo "ქვედაყანოფები მხოლოდ HASH და KEY დანაყოფებს შეიძლება წარმოადგენდეს"
spa "Las subparticiones sólo pueden ser particiones dispersas (hash) y mediante clave"
swe "Subpartitioner kan bara vara hash och key partitioner"
ER_PARTITION_SUBPART_MIX_ERROR
chi "如果在一个分区上,必须在所有分区上定义子组分"
eng "Must define subpartitions on all partitions if on one partition"
ger "Wenn Sie Unterpartitionen auf einer Partition definieren, müssen Sie das für alle Partitionen tun"
+ geo "თუ ქვედანაყოფს ერთ დანაყოფზე მაინც აღწერთ, ისინი ყველა დანაყოფზე უნდა აღწეროთ"
spa "Se deben de definir subparticiones en todas las particiones si se está en una partición"
swe "Subpartitioner måste definieras på alla partitioner om på en"
ER_PARTITION_WRONG_NO_PART_ERROR
chi "定义了错误的分区数,与以前的设置不匹配"
eng "Wrong number of partitions defined, mismatch with previous setting"
ger "Falsche Anzahl von Partitionen definiert, stimmt nicht mit vorherigen Einstellungen überein"
+ geo "აღწერილია დანაყოფების არასწორი რაოდენობა. ის წინა პარამეტრს არ ემთხვევა"
spa "Definido un número equivocado de particiones, no coincide con configuración previa"
swe "Antal partitioner definierade och antal partitioner är inte lika"
ER_PARTITION_WRONG_NO_SUBPART_ERROR
chi "错误的子组分数定义,与以前的设置不匹配"
eng "Wrong number of subpartitions defined, mismatch with previous setting"
ger "Falsche Anzahl von Unterpartitionen definiert, stimmt nicht mit vorherigen Einstellungen überein"
+ geo "აღწერილია ქვედაყანოფეის არასწორი რაოდენობა. ის წინა პარამეტრს არ ემთხვევა"
spa "Definido un número equivocado de subparticiones, no coincide con configuración previa"
swe "Antal subpartitioner definierade och antal subpartitioner är inte lika"
ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
chi "不允许(子)分区功能中的常量,随机或时区依赖表达式"
eng "Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed"
ger "Konstante oder Random-Ausdrücke in (Unter-)Partitionsfunktionen sind nicht erlaubt"
+ geo "(ქვე)დაყოფის ფუნქციაში მუდმივი, შემთხვევითი და დროის სარტყელზე დამოკიდებული გამოსახულებების გამოყენება დაშვებული არაა"
spa "Las expresiones constantes, al azar o dependientes de zona en función de (sub)particionado no están permitidas"
swe "Konstanta uttryck eller slumpmässiga uttryck är inte tillåtna (sub)partitioneringsfunktioner"
ER_NOT_CONSTANT_EXPRESSION
chi "%s中的表达必须是恒定的"
eng "Expression in %s must be constant"
ger "Ausdrücke in %s müssen konstant sein"
+ geo "%s-ში გამოსახულება მუდმივი უნდა იყოს"
spa "Las expresiones incluidas en %s deben de ser constantes"
swe "Uttryck i %s måste vara ett konstant uttryck"
ER_FIELD_NOT_FOUND_PART_ERROR
chi "在表中找不到分区功能的字段列表中的字段"
eng "Field in list of fields for partition function not found in table"
ger "Felder in der Feldliste der Partitionierungsfunktion wurden in der Tabelle nicht gefunden"
+ geo "ველი დაყოფის ფუნქციისთვის ცხრილის ველების სიაში აღმოჩენილი არაა"
spa "Campo en la lista de campos para función de partición no hallado en tabla"
swe "Fält i listan av fält för partitionering med key inte funnen i tabellen"
ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR
chi "只允许在索引分区中允许字段列表"
eng "List of fields is only allowed in KEY partitions"
ger "Eine Feldliste ist nur in KEY-Partitionen erlaubt"
+ geo "ველების სია მხოლოდ KEY დანაყოფებზეა დაშვებული"
spa "Lista de campos sólo se permite en particiones KEY"
swe "En lista av fält är endast tillåtet för KEY partitioner"
ER_INCONSISTENT_PARTITION_INFO_ERROR
chi "FRM文件中的分区信息不与可以写入FRM文件的内容一致"
eng "The partition info in the frm file is not consistent with what can be written into the frm file"
ger "Die Partitionierungsinformationen in der frm-Datei stimmen nicht mit dem überein, was in die frm-Datei geschrieben werden kann"
+ geo "დანაყოფების შესახებ ინფორმაცია frm ფაილშიარ ემთხვევა იმას, რაც frm ფაილში წერია"
spa "La información de partición en el fichero/archivo frm no es consistente con lo que se puede grabar en un fichero/archivo frm"
swe "Partitioneringsinformationen i frm-filen är inte konsistent med vad som kan skrivas i frm-filen"
ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
chi "%-.192s函数返回错误的类型"
eng "The %-.192s function returns the wrong type"
ger "Die %-.192s-Funktion gibt einen falschen Typ zurück"
+ geo "ფუნქცია %-.192s არასწორ ტიპს აბრუნებს"
spa "La función %-.192s devueve un tipo equivocado"
swe "%-.192s-funktionen returnerar felaktig typ"
ER_PARTITIONS_MUST_BE_DEFINED_ERROR
chi "对于%-.64s分区必须定义每个分区"
eng "For %-.64s partitions each partition must be defined"
ger "Für %-.64s-Partitionen muss jede Partition definiert sein"
+ geo "%-.64s დანაყოფებისთვის ყველა დანაყოფი უნდა აღიწეროს"
spa "Para las particiones %-.64s, se debe de definir cada partición"
swe "För %-.64s partitionering så måste varje partition definieras"
ER_RANGE_NOT_INCREASING_ERROR
chi "每个分区的VALUES LESS THAN的值必须严格增加"
eng "VALUES LESS THAN value must be strictly increasing for each partition"
ger "Werte in VALUES LESS THAN müssen für jede Partition strikt aufsteigend sein"
+ geo "VALUES LESS THAN მნიშვნელობები თითოეული დანაყოფისთვის მხოლოდ უნდა იზრდებოდეს"
spa "El valor VALUES LESS THAN debe de ser estrictamente incremental para cada partición"
swe "Värden i VALUES LESS THAN måste vara strikt växande för varje partition"
ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
chi "VALUES值必须与分区函数相同"
eng "VALUES value must be of same type as partition function"
ger "VALUES-Werte müssen vom selben Typ wie die Partitionierungsfunktion sein"
+ geo "VALUES მნისვნელობა დანაყოფის ფუნქციის ტიპის უნდა იყოს"
spa "El valor VALUES debe de ser del mismo tipo que la función de partición"
swe "Värden i VALUES måste vara av samma typ som partitioneringsfunktionen"
ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
chi "列表分区中相同常量的多个定义"
eng "Multiple definition of same constant in list partitioning"
ger "Mehrfachdefinition derselben Konstante bei Listen-Partitionierung"
+ geo "სიის დანაყოფებში აღმოჩენილია მუდმივის ერთზე მეტი აღწერა"
spa "Definición múltiple de la misma constante en el particionamiento de la lista"
swe "Multipel definition av samma konstant i list partitionering"
ER_PARTITION_ENTRY_ERROR
chi "分区不能在查询中独立使用"
eng "Partitioning can not be used stand-alone in query"
ger "Partitionierung kann in einer Abfrage nicht alleinstehend benutzt werden"
+ geo "დაყოფა არ შეიძლება, მოთხოვნაში ცალკე გამოიყენოთ"
spa "El particionado no puede ser usado de forma autónoma en consulta (query)"
swe "Partitioneringssyntax kan inte användas på egen hand i en SQL-fråga"
ER_MIX_HANDLER_ERROR
chi "此版本的MariaDB中不允许分区中的处理程序混合"
eng "The mix of handlers in the partitions is not allowed in this version of MariaDB"
ger "Das Vermischen von Handlern in Partitionen ist in dieser Version von MariaDB nicht erlaubt"
+ geo "MariaDB-ის ამ ვერსიაში დანაყოფებში დამმუშავებლების შერევა დაშვებული არაა"
spa "La mezcla de manejadores en las particiones no está autorizada en esta versión de MariaDB"
swe "Denna mix av lagringsmotorer är inte tillåten i denna version av MariaDB"
ER_PARTITION_NOT_DEFINED_ERROR
chi "对于分区引擎,需要定义所有%-.64s"
eng "For the partitioned engine it is necessary to define all %-.64s"
ger "Für die partitionierte Engine müssen alle %-.64s definiert sein"
+ geo "დაყოფის ძრავისთვის ყველა %-.64s-ის აღწერა აუცილებელია"
spa "Para el motor de particionado es necesario definir todas %-.64s"
swe "För partitioneringsmotorn så är det nödvändigt att definiera alla %-.64s"
ER_TOO_MANY_PARTITIONS_ERROR
chi "定义了太多分区(包括子组分)"
eng "Too many partitions (including subpartitions) were defined"
ger "Es wurden zu vielen Partitionen (einschließlich Unterpartitionen) definiert"
+ geo "აღწერილია მეტისმეტად ბევრი დანაყოფი (ქვედანაყოფების ჩათვლით)"
spa "Definidas demasiadas particiones (incluyendo las subparticiones)"
swe "För många partitioner (inkluderande subpartitioner) definierades"
ER_SUBPARTITION_ERROR
@@ -6608,79 +7101,93 @@ ER_CANT_CREATE_HANDLER_FILE
chi "无法创建特定的处理程序文件"
eng "Failed to create specific handler file"
ger "Erzeugen einer spezifischen Handler-Datei fehlgeschlagen"
+ geo "მითითებული დამმუშავებლის ფაილის შექმნის შეცდომა"
spa "No pude crear fichero/archivo de manejador específico"
swe "Misslyckades med att skapa specifik fil i lagringsmotor"
ER_BLOB_FIELD_IN_PART_FUNC_ERROR
chi "分区功能中不允许BLOB字段"
eng "A BLOB field is not allowed in partition function"
ger "In der Partitionierungsfunktion sind BLOB-Spalten nicht erlaubt"
+ geo "დანაყოფის ფუნქციაში BLOB ველი დაშვებული არაა"
spa "No se autoriza campo BLOB en la función de partición"
swe "Ett BLOB-fält är inte tillåtet i partitioneringsfunktioner"
ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
chi "A%-.192s必须包含表的分区功能中的所有列"
eng "A %-.192s must include all columns in the table's partitioning function"
+ geo "%-.192s ცხრილის დაყოფის ფუნქციაში ყველა სვეტს უნდა შეიცავდეს"
spa "Un %-.192s debe de incluir todas las columnas en la función de particionado de la tabla"
ER_NO_PARTS_ERROR
chi "不允许%-.64s = 0"
eng "Number of %-.64s = 0 is not an allowed value"
ger "Eine Anzahl von %-.64s = 0 ist kein erlaubter Wert"
+ geo "%-.64s = 0 რაოდენობა დაშვებული არაა"
spa "El número de %-.64s = 0 no es un valor autorizado"
swe "Antal %-.64s = 0 är inte ett tillåten värde"
ER_PARTITION_MGMT_ON_NONPARTITIONED
chi "不分区表上的分区管理是不可能的"
eng "Partition management on a not partitioned table is not possible"
ger "Partitionsverwaltung einer nicht partitionierten Tabelle ist nicht möglich"
+ geo "დანაყოფების მართვა ცხრილზე, რომელიც დაყოფილი არაა, შეუძლებელია"
spa "La gestión de particiones en una tabla no particionada no es posible"
swe "Partitioneringskommando på en opartitionerad tabell är inte möjligt"
ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING
eng "Partitioned tables do not support %s"
+ geo "დაყოფილ ცხრილებს %s-ის მხარდაჭერა არ გააჩნიათ"
spa "Las tablas particionadas no soportan %s"
ER_PARTITION_DOES_NOT_EXIST
chi "分区名称或分区列表错误"
eng "Wrong partition name or partition list"
ger "Falscher Name einer Partition oder Fehler in der Partitionsliste"
+ geo "დანაყოფის არასწორი სახელი ან დანაყოფების სია"
spa "Error en lista de particiones"
swe "Fel namn av en partition eller fel i listan av partitioner"
ER_DROP_LAST_PARTITION
chi "无法删除所有分区,请使用删除表"
eng "Cannot remove all partitions, use DROP TABLE instead"
ger "Es lassen sich nicht sämtliche Partitionen löschen, benutzen Sie statt dessen DROP TABLE"
+ geo "ყველა დანაყოფის წაშლა შეუძლებელია. ამისთვის DROP TABLE გამოიყენეთ"
spa "No puedo quitar todas las particiones, use DROP TABLE en su lugar"
swe "Det är inte tillåtet att ta bort alla partitioner, använd DROP TABLE istället"
ER_COALESCE_ONLY_ON_HASH_PARTITION
chi "COALESCE分区只能用于哈希/索引分区"
eng "COALESCE PARTITION can only be used on HASH/KEY partitions"
ger "COALESCE PARTITION kann nur auf HASH- oder KEY-Partitionen benutzt werden"
+ geo "COALESCE PARTITION-ის გამოყენება მხოლოდ HASH/KEY დანაყოფებზეა შესაძლებელი"
spa "COALESCE PARTITION sólo se puede usar en particiones HASH/KEY"
swe "COALESCE PARTITION kan bara användas på HASH/KEY partitioner"
ER_REORG_HASH_ONLY_ON_SAME_NO
chi "REORGANIZE PARTITION只能用于重新组织不改变他们的数字的分区"
eng "REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers"
ger "REORGANIZE PARTITION kann nur zur Reorganisation von Partitionen verwendet werden, nicht, um ihre Nummern zu ändern"
+ geo "REORGANIZE PARTITION-ის გამოყენება მხოლოდ დანაყოფების გადასალაგებლადაა შესაძლებელი და არა მათი ნომრების შესაცვლელად"
spa "REORGANIZE PARTITION sólo se puede usar para reorganizar particiones no para cambiar sus números"
swe "REORGANIZE PARTITION kan bara användas för att omorganisera partitioner, inte för att ändra deras antal"
ER_REORG_NO_PARAM_ERROR
chi "没有参数的REORGANIZE PARTITION只能用于HASH PARTITION的自动分区表"
eng "REORGANIZE PARTITION without parameters can only be used on auto-partitioned tables using HASH PARTITIONs"
ger "REORGANIZE PARTITION ohne Parameter kann nur für auto-partitionierte Tabellen verwendet werden, die HASH-Partitionierung benutzen"
+ geo "REORGANIZE PARTITION-ის პარამეტრების გარეშე გამოყენება HASH PARTITION-ის გამოყენებით ავტომატურად დაყოფილ ცხრილებზეა შესაძლებელი"
spa "REORGANIZE PARTITION sin parámetros sólo se puede usar en tablas auto-particionadas usando HASH PARTITIONs"
swe "REORGANIZE PARTITION utan parametrar kan bara användas på auto-partitionerade tabeller som använder HASH partitionering"
ER_ONLY_ON_RANGE_LIST_PARTITION
chi "%-.64s分区只能用于RANGE/LIST分区"
eng "%-.64s PARTITION can only be used on RANGE/LIST partitions"
ger "%-.64s PARTITION kann nur für RANGE- oder LIST-Partitionen verwendet werden"
+ geo "%-.64s PARTITION-ის გამოყენება მხოლოდ RANGE/LIST ტიპის დანაყოფებზეა შესაძლებელი"
spa "%-.64s PARTITION sólo puede ser usada en particiones RANGE/LIST"
swe "%-.64s PARTITION kan bara användas på RANGE/LIST-partitioner"
ER_ADD_PARTITION_SUBPART_ERROR
chi "尝试用错误数量的子分区添加分区"
eng "Trying to Add partition(s) with wrong number of subpartitions"
ger "Es wurde versucht, eine oder mehrere Partitionen mit der falschen Anzahl von Unterpartitionen hinzuzufügen"
+ geo "არასწორი ქვედანაყოფების რაოდენობის მქონე დანაყოფების დამატების მცდელობა"
spa "Intentando añadir particion(es) usando un número equivocado de subparticiones"
swe "ADD PARTITION med fel antal subpartitioner"
ER_ADD_PARTITION_NO_NEW_PARTITION
chi "必须添加至少一个分区"
eng "At least one partition must be added"
ger "Es muss zumindest eine Partition hinzugefügt werden"
+ geo "აუცილებელია, ერთი დანაყოფი მაინც დაამატოთ"
spa "Se debe de añadir una partición, al menos"
swe "Åtminstone en partition måste läggas till vid ADD PARTITION"
ER_COALESCE_PARTITION_NO_PARTITION
@@ -6699,12 +7206,14 @@ ER_SAME_NAME_PARTITION
chi "重复分区名称%-.192s"
eng "Duplicate partition name %-.192s"
ger "Doppelter Partitionsname: %-.192s"
+ geo "დუბლირებული დანაყოფის სახელი %-.192s"
spa "Nombre de partición duplicado %-.192s"
swe "Duplicerat partitionsnamn %-.192s"
ER_NO_BINLOG_ERROR
chi "在此命令上不允许关闭binlog"
eng "It is not allowed to shut off binlog on this command"
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
+ geo "ამ ბრძანებაზე binlog-ის გამორთვა აკრძალულია"
spa "No se autoriza a apagar binlog con este comando"
swe "Det är inte tillåtet att stänga av binlog på detta kommando"
ER_CONSECUTIVE_REORG_PARTITIONS
@@ -6734,157 +7243,187 @@ ER_LIMITED_PART_RANGE
chi "%-.64s处理程序仅支持32-bit整数"
eng "The %-.64s handler only supports 32 bit integers in VALUES"
ger "Der Handler %-.64s unterstützt in VALUES nur 32-Bit-Integers"
+ geo "'%-.64s'-ის დამმუშავებელს VALUES-ში მხოლოდ 32 ბიტიანი მთელი რიცხვების მხარდაჭერა გააჩნია"
spa "El manejador %-.64s sólo soporta enteros de 32 bit en VALUES"
swe "%-.64s stödjer endast 32 bitar i integers i VALUES"
ER_PLUGIN_IS_NOT_LOADED
chi "插件'%-.192s'未加载"
eng "Plugin '%-.192s' is not loaded"
ger "Plugin '%-.192s' ist nicht geladen"
+ geo "დამატება '%-.192s' ჩატვირთული არაა"
spa "Enchufe (plugin) '%-.192s' no cargado"
ER_WRONG_VALUE
chi "错误%-.32s值:'%-.128T'"
eng "Incorrect %-.32s value: '%-.128T'"
ger "Falscher %-.32s-Wert: '%-.128T'"
+ geo "%-.32s-ის არასწორი მნიშვნელობა: '%-.128T'"
spa "Incorrecto %-.32s valor: '%-.128T'"
ER_NO_PARTITION_FOR_GIVEN_VALUE
chi "表没有%-.64s的分区"
eng "Table has no partition for value %-.64s"
ger "Tabelle hat für den Wert %-.64s keine Partition"
+ geo "ცხრილს მნიშვნელობისთვის %-.64s დანაყოფი არ გააჩნია"
spa "La tabla no tiene partición para valor %-.64s"
ER_FILEGROUP_OPTION_ONLY_ONCE
chi "设置%s不能超过一次"
eng "It is not allowed to specify %s more than once"
ger "%s darf nicht mehr als einmal angegegeben werden"
+ geo "%s-ის მითითება მხოლოდ ერთხელ შეგიძლიათ"
spa "No se permite especificar %s más de unva vez"
ER_CREATE_FILEGROUP_FAILED
chi "无法创建%s"
eng "Failed to create %s"
ger "Anlegen von %s fehlgeschlagen"
+ geo "%s-ის შექმნის შეცდომა"
hindi "%s को बनाने में असफल रहे"
spa "No pude crear %s"
ER_DROP_FILEGROUP_FAILED
chi "未能DROP%s"
eng "Failed to drop %s"
ger "Löschen von %s fehlgeschlagen"
+ geo "%s-ის წაშლის შეცდომა"
hindi "%s को हटाने में असफल रहे"
spa "No pude eliminar %s"
ER_TABLESPACE_AUTO_EXTEND_ERROR
chi "处理程序不支持表空间的自动扩展名"
eng "The handler doesn't support autoextend of tablespaces"
ger "Der Handler unterstützt keine automatische Erweiterung (Autoextend) von Tablespaces"
+ geo "დამმუშავებელს ცხრილის სივრცეების ავტომატური გაფართოების მხარდაჭერა არ გააჩნია"
spa "El manejador no soporta autoextensión de espacios de tabla"
ER_WRONG_SIZE_NUMBER
chi "尺寸参数被错误地指定,编号或表单10M"
eng "A size parameter was incorrectly specified, either number or on the form 10M"
ger "Ein Größen-Parameter wurde unkorrekt angegeben, muss entweder Zahl sein oder im Format 10M"
+ geo "ზომის პარამეტრი არასწორადაა მითითბული, ან რიცხვით, ან ფორმით '1M'"
spa "Se ha especificado de forma incorrecta un parámetro de medida o el número o en la forma 10M"
ER_SIZE_OVERFLOW_ERROR
chi "尺寸编号是正确的,但我们不允许数字部分超过20亿"
eng "The size number was correct but we don't allow the digit part to be more than 2 billion"
ger "Die Zahl für die Größe war korrekt, aber der Zahlanteil darf nicht größer als 2 Milliarden sein"
+ geo "ზომის სიდიდე სწორია, მაგრამ ამჟამად ჩვენ 2 მილიარდზე მეტი ნაწილის მხარდაჭერ არ გაგვაჩნია"
spa "El número de medida es correcto pero no permitimos que la parte del dígito tenga más de 2 billones"
ER_ALTER_FILEGROUP_FAILED
chi "未能改变:%s"
eng "Failed to alter: %s"
ger "Änderung von %s fehlgeschlagen"
+ geo "ცვლილების შეცდომა: %s"
hindi "%s को ALTER करने में असफल रहे"
spa "No pude alterar: %s"
ER_BINLOG_ROW_LOGGING_FAILED
chi "将一行写入基于行的二进制日志失败"
eng "Writing one row to the row-based binary log failed"
ger "Schreiben einer Zeilen ins zeilenbasierte Binärlog fehlgeschlagen"
+ geo "მწკრივებზე დაფუძლებულ ბინარულ ჟურნალში ერთი მწკრივის ჩაწერის შეცდომა"
spa "Ha fallado el grabar una fila en historial (log) binario basado en fila"
ER_BINLOG_ROW_WRONG_TABLE_DEF
chi "表定义主机和从站不匹配:%s"
eng "Table definition on master and slave does not match: %s"
ger "Tabellendefinition auf Master und Slave stimmt nicht überein: %s"
+ geo "მთავარ და დამორჩილებულ სერვერებზე ცხრილის აღწერა ერთმანეთს არ ემთხვევა: %s"
spa "La definición de tabla en maestro (master) y esclavo no coincide: %s"
ER_BINLOG_ROW_RBR_TO_SBR
chi "使用--log-slave-updates的从站必须使用基于行的二进制日志记录,以便能够复制基于行的二进制日志事件"
eng "Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events"
ger "Slave, die mit --log-slave-updates laufen, müssen zeilenbasiertes Loggen verwenden, um zeilenbasierte Binärlog-Ereignisse loggen zu können"
+ geo "დამორჩილებული, რომელიც --log-slave-updates პარამეტრითაა გაშვებული, მწკრივებზე დაფუძნებული ბინარული ჟურნალის მოვლენების რეპლიკაციისთვის მწკრივებზე-დამოკიდებულ ბინარულ ჟურნალს უნდა იყენებდეს"
spa "La ejecución esclava con --log-slave-updates debe de usar un historial (log) binario basado en fila para que pueda replicar eventos de historial (log) binario basados en fila"
ER_EVENT_ALREADY_EXISTS
chi "事件'%-.192s'已经存在"
eng "Event '%-.192s' already exists"
ger "Event '%-.192s' existiert bereits"
+ geo "მოვლენა '%-.192s' უკვე არსებობს"
spa "El evento '%-.192s' ya existe"
ER_EVENT_STORE_FAILED
chi "无法存储事件%s。错误代码%M来自存储引擎"
eng "Failed to store event %s. Error code %M from storage engine"
ger "Speichern von Event %s fehlgeschlagen. Fehlercode der Speicher-Engine: %M"
+ geo "%s მოვლენის დამახსოვრების შეცდომა. საცავის ძრავიდან მიღებული შეცდომის კოდია %M"
spa "No pude almacenar evento %s. Código de error %M desde motor de almacenaje"
ER_EVENT_DOES_NOT_EXIST
chi "未知事件'%-.192s'"
eng "Unknown event '%-.192s'"
ger "Unbekanntes Event '%-.192s'"
+ geo "უცნობი მოვლენა '%-.192s'"
spa "Evento desconocido '%-.192s'"
ER_EVENT_CANT_ALTER
chi "无法改变事件'%-.192s'"
eng "Failed to alter event '%-.192s'"
ger "Ändern des Events '%-.192s' fehlgeschlagen"
+ geo "მოვლენის ('%-.192s') ჩასწორების შეცდომა"
hindi "'%-.192s' EVENT को ALTER करने में असफल रहे"
spa "No pude alterar evento '%-.192s'"
ER_EVENT_DROP_FAILED
chi "未能DROP%s"
eng "Failed to drop %s"
ger "Löschen von %s fehlgeschlagen"
+ geo "%s-ის წაშლის შეცდომა"
hindi "%s को हटाने में असफल रहे"
spa "No pude eliminar %s"
ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
chi "INTERVAL为负或太大"
eng "INTERVAL is either not positive or too big"
ger "INTERVAL ist entweder nicht positiv oder zu groß"
+ geo "INTERVAL-ის მნიშვნელობა დადებითი არაა ან ძალიან დიდია"
spa "O INTERVAL no es positivo o es demasiado grande"
ER_EVENT_ENDS_BEFORE_STARTS
chi "ENDS无效的或在STARTS之前"
eng "ENDS is either invalid or before STARTS"
ger "ENDS ist entweder ungültig oder liegt vor STARTS"
+ geo "ENDS ან არასწორია, ან STARTS-ის წინაა"
spa "O ENDS es inválido o anterior a STARTS"
ER_EVENT_EXEC_TIME_IN_THE_PAST
chi "事件执行时间在过去。事件已被禁用"
eng "Event execution time is in the past. Event has been disabled"
ger "Ausführungszeit des Events liegt in der Vergangenheit. Event wurde deaktiviert"
+ geo "მოვლენის შესრულების დრო წარსულშია. მოვლენა გაითიშა"
spa "El tiempo de ejecución de evento se encuentra en el pasado. El evento ha sido desactivado"
ER_EVENT_OPEN_TABLE_FAILED
chi "无法打开mysql.event"
eng "Failed to open mysql.event"
ger "Öffnen von mysql.event fehlgeschlagen"
+ geo "mysql.event-ის გახსნის შეცდომა"
hindi "mysql.event को खोलने में असफल रहे"
spa "No puede abrir mysql.event"
ER_EVENT_NEITHER_M_EXPR_NOR_M_AT
chi "没有提供DateTime表达式"
eng "No datetime expression provided"
ger "Kein DATETIME-Ausdruck angegeben"
+ geo "დრო/თარიღის გამოსახულება მითითებული არაა"
spa "No se ha suministrado expresión datetime"
ER_UNUSED_2
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას წესით ვერ უნდა ხედავდეთ"
spa "No lo debería vd de ver nunca"
ER_UNUSED_3
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას წესით ვერასდროს უნდა ხედავდეთ"
spa "No lo debería vd de ver nunca"
ER_EVENT_CANNOT_DELETE
chi "无法从mysql.event删除该事件"
eng "Failed to delete the event from mysql.event"
ger "Löschen des Events aus mysql.event fehlgeschlagen"
+ geo "mysql.event-დან მოვლენის წაშლის შეცდომა"
hindi "EVENT को mysql.event से हटाने मैं असफल रहे"
spa "No pude borrar el evento desde mysql.event"
ER_EVENT_COMPILE_ERROR
chi "在汇编事件的主体时出错"
eng "Error during compilation of event's body"
ger "Fehler beim Kompilieren des Event-Bodys"
+ geo "მოვლენის ტანის აგების შეცდომა"
spa "Error durante compilación de cuerpo de evento"
ER_EVENT_SAME_NAME
chi "相同的旧活动名称"
eng "Same old and new event name"
ger "Alter und neuer Event-Name sind gleich"
+ geo "ძველი და ახალი მოვლენის სახელების იგივეა"
spa "Mismo nombre de evento viejo y nuevo"
ER_EVENT_DATA_TOO_LONG
chi "列'%s'数据太长"
eng "Data for column '%s' too long"
ger "Daten der Spalte '%s' zu lang"
+ geo "მონაცემები სვეტისთვის '%s' ძალიან გრძელია"
spa "Datos demasiado largos para la columna '%s'"
ER_DROP_INDEX_FK
chi "无法删除索引'%-.192s':外部索引约束中需要它"
@@ -6897,80 +7436,95 @@ ER_WARN_DEPRECATED_SYNTAX_WITH_VER
chi "语法'%s'被弃用,将在Mariadb%s中删除。请使用%s"
eng "The syntax '%s' is deprecated and will be removed in MariaDB %s. Please use %s instead"
ger "Die Syntax '%s' ist veraltet und wird in MariaDB %s entfernt. Bitte benutzen Sie statt dessen %s"
+ geo "სინტაქსი '%s' მოძველებულია და MariaDB %s-ში წაიშლება. გამოიეყენეთ %s"
spa "La sintaxis '%s' está obsoleta y será quitada en MariaDB %s. Por favor, use %s en su lugar"
ER_CANT_WRITE_LOCK_LOG_TABLE
chi "您无法获得日志表的写锁。只有读访问是可能的"
eng "You can't write-lock a log table. Only read access is possible"
ger "Eine Log-Tabelle kann nicht schreibgesperrt werden. Es ist ohnehin nur Lesezugriff möglich"
+ geo "ჟურნალის ცხრილის ჩაწერაზე დაბლოკვა შეუძლებელია. შესაძლებელია მხოლოდ წაკითხვა"
spa "No puede hacer bloqueo de escritura en una tabla de historial (log). Sólo es posible acceso de lectura"
ER_CANT_LOCK_LOG_TABLE
chi "您无法使用带日志表的锁"
eng "You can't use locks with log tables"
ger "Log-Tabellen können nicht gesperrt werden"
+ geo "ჟურნალის ცხრილის დაბლოკვა შეუძლებელია"
spa "No puede usar bloqueos con tablas de historial (log)"
ER_UNUSED_4
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერ უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE
chi "mysql的列计数。%s是错误的。预期%d,找到%d。使用MariaDB%d创建,现在运行%d。请使用mariadb-upgrade来修复此错误"
eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created with MariaDB %d, now running %d. Please use mariadb-upgrade to fix this error"
ger "Spaltenanzahl von mysql.%s falsch. %d erwartet, aber %d erhalten. Erzeugt mit MariaDB %d, jetzt unter %d. Bitte benutzen Sie mariadb-upgrade, um den Fehler zu beheben"
+ geo "mysql.%s-ის სვეტების რაოდენობა არასწორია. მოველოდი: %d, მივიღე: %d. შექმნილია MaraDB-ის ვერსიით %d, ახლა კი გაქვთ %d. am შეცდომის გასასწორებლად mariadb-upgrade გაუშვით"
spa "El contador de columnas de mysql.%s está equivocado. Se esperaba %d, hallado %d. Creado con MariaDB %d, ahora ejecuando %d. Por favor, use mariadb-upgrade para solucionar este error"
ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
chi "当会话打开临时表时,无法切换出基于行的二进制日志格式"
eng "Cannot switch out of the row-based binary log format when the session has open temporary tables"
ger "Kann nicht aus dem zeilenbasierten Binärlog-Format herauswechseln, wenn die Sitzung offene temporäre Tabellen hat"
+ geo "როცა სესიას ღია დროებითი ცხრილები გააჩნია, მწკრივებზე დაფუძნებული ბინარული ჟურნალის ფორმატის გადართვა შეუძლებელია"
spa "No puedo conmutar fuera del formato de historial (log) binario basado en fila cuando la sesión ha abierto tablas temporales"
ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT
chi "无法更改存储函数或触发器内的二进制记录格式"
eng "Cannot change the binary logging format inside a stored function or trigger"
ger "Das Binärlog-Format kann innerhalb einer gespeicherten Funktion oder eines Triggers nicht geändert werden"
+ geo "შენახულიფუნქციის და ტრიგერის შიგნიდან ბინარული ჟურნალის ფორმატის შეცვლა შეუძლებელია"
spa "No puedo cambiar el formato de historial (log) binario dentro de funciones almacenadas o disparadores"
ER_UNUSED_13
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "მას ვერ უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_PARTITION_NO_TEMPORARY
chi "无法使用分区创建临时表"
eng "Cannot create temporary table with partitions"
ger "Anlegen temporärer Tabellen mit Partitionen nicht möglich"
+ geo "დანაყოფების მქონე დროებითი ცხრილის შექმნა შეუძლებელია"
hindi "अस्थाई टेबल को पार्टिशन्स के साथ नहीं बनाया जा सकता"
spa "No puedo crear tabla temporal con particiones"
ER_PARTITION_CONST_DOMAIN_ERROR
chi "分区常量超出分区功能域"
eng "Partition constant is out of partition function domain"
ger "Partitionskonstante liegt außerhalb der Partitionsfunktionsdomäne"
+ geo "დანაყოფის მუდმივა დანაყოფის ფუნქციის დომენის გარეთაა"
spa "La constante de partición está fuera del dominio de función de partición"
swe "Partitionskonstanten är utanför partitioneringsfunktionens domän"
ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
chi "不允许此分区功能"
eng "This partition function is not allowed"
ger "Diese Partitionierungsfunktion ist nicht erlaubt"
+ geo "დაყოფის ეს ფუნქცია დაშვებული არაა"
spa "Esta función de partición no está permitida"
swe "Denna partitioneringsfunktion är inte tillåten"
ER_DDL_LOG_ERROR
chi "DDL日志中的错误"
eng "Error in DDL log"
ger "Fehler im DDL-Log"
+ geo "შეცდომა DDL-ის ჟურნალში"
hindi "DDL लॉग में त्रुटि हुई"
spa "Error en historial (log) DDL"
ER_NULL_IN_VALUES_LESS_THAN
chi "VALUES LESS THAN不允许使用NULL"
eng "Not allowed to use NULL value in VALUES LESS THAN"
ger "In VALUES LESS THAN dürfen keine NULL-Werte verwendet werden"
+ geo "VALUES LESS THAN-ში NULL მნიშვნელობა დაუშვებელია"
spa "No autorizado a usar valor NULL en VALUES LESS THAN"
swe "Det är inte tillåtet att använda NULL-värden i VALUES LESS THAN"
ER_WRONG_PARTITION_NAME
chi "分区名称不正确"
eng "Incorrect partition name"
ger "Falscher Partitionsname"
+ geo "დანაყოფის არასწორი სახელი"
hindi "पार्टीशन का नाम गलत है"
spa "Nombre incorrecto de partición"
swe "Felaktigt partitionsnamn"
ER_CANT_CHANGE_TX_CHARACTERISTICS 25001
chi "交易正在进行,无法更改事务特性"
eng "Transaction characteristics can't be changed while a transaction is in progress"
+ geo "ტრანზაქციის მიმდინარეობისას მისი მახასიათებლების შეცვლა შეუძლებელია"
spa "No se pueden cambiar las característias de transacción mientras que una transacción se ecuentre en proceso"
ER_DUP_ENTRY_AUTOINCREMENT_CASE
chi "ALTER TABLE表会导致AUTO_INCREMENT重建,导致重复的条目'%-.192T'用于索引'%-.192s'"
@@ -6981,59 +7535,70 @@ ER_EVENT_MODIFY_QUEUE_ERROR
chi "内部调度器错误%d"
eng "Internal scheduler error %d"
ger "Interner Scheduler-Fehler %d"
+ geo "შიდა დამგეგმავის შეცდომა %d"
spa "Error en organizador interno %d"
ER_EVENT_SET_VAR_ERROR
chi "在开始/停止调度程序期间出错。错误代码%M"
eng "Error during starting/stopping of the scheduler. Error code %M"
ger "Fehler während des Startens oder Anhalten des Schedulers. Fehlercode %M"
+ geo "შეცდომა დამგეგმავის გაშვება/გაჩერებისას. შეცდომის კოდია %M"
spa "Error durante arranque/parada del organizador. Código de error %M"
ER_PARTITION_MERGE_ERROR
chi "引擎不能用于分区表"
eng "Engine cannot be used in partitioned tables"
ger "Engine kann in partitionierten Tabellen nicht verwendet werden"
+ geo "ძრავას დაყოფილ ცხრილებში ვერ გამოიყენებთ"
spa "No se puede usar el motor en tablas particionadas"
swe "Engine inte användas i en partitionerad tabell"
ER_CANT_ACTIVATE_LOG
chi "无法激活'%-.64s'日志"
eng "Cannot activate '%-.64s' log"
ger "Kann Logdatei '%-.64s' nicht aktivieren"
+ geo "'%-.64s' ჟურნალის აქტივაცია შეუძლებელია"
spa "No puedo activar historial (log) '%-.64s'"
ER_RBR_NOT_AVAILABLE
chi "服务器不是基于行的复制构建的"
eng "The server was not built with row-based replication"
ger "Der Server wurde nicht mit zeilenbasierter Replikation gebaut"
+ geo "სერვერის აგების დროს მწკრივებზე დაფუძნებული რეპლიკაცია ჩართული არ იყო"
spa "El servidor no ha sido construido con réplica basada en fila"
ER_BASE64_DECODE_ERROR
chi "Base64字符串的解码失败"
eng "Decoding of base64 string failed"
ger "Der Server hat keine zeilenbasierte Replikation"
+ geo "base64 სტრიქონის გაშიფვრის შეცდომა"
spa "Ha fallado la decodificación de cadena base64"
swe "Avkodning av base64 sträng misslyckades"
ER_EVENT_RECURSION_FORBIDDEN
chi "EVENT主体存在时EVENT DDL语句递归被禁止"
eng "Recursion of EVENT DDL statements is forbidden when body is present"
ger "Rekursivität von EVENT-DDL-Anweisungen ist unzulässig wenn ein Hauptteil (Body) existiert"
+ geo "როცა სხეული არსებობს, EVENT DDL გამოსახულებების რეკურსია დაშვებული არაა"
spa "Se prohiben sentencias de EVENT DDL cuando se encuentra presente el cuerpo"
ER_EVENTS_DB_ERROR
chi "无法继续,因为事件调度程序已禁用"
eng "Cannot proceed, because event scheduler is disabled"
ger "Die Operation kann nicht fortgesetzt werden, da Event Scheduler deaktiviert ist."
+ geo "გაგრძელება შეუძლებელია, რადგან მოვლენების დამგეგმავი გამორთულია"
spa "No puedo proceder porque el organizado de eventos está desactivado"
ER_ONLY_INTEGERS_ALLOWED
chi "这里只允许整数作为数字"
eng "Only integers allowed as number here"
ger "An dieser Stelle sind nur Ganzzahlen zulässig"
+ geo "აქ მხოლოდ მთელი რიცხვის გამოყენება შეგიძლიათ"
spa "Sólo se permiten enteros como número aquí"
ER_UNSUPORTED_LOG_ENGINE
chi "存储引擎%s不能用于日志表"
eng "Storage engine %s cannot be used for log tables"
ger "Speicher-Engine %s kann für Logtabellen nicht verwendet werden"
+ geo "ჟურნალის ცხრილებისთვის საცავის ძრავას %s ვერ გამოიყენებთ"
hindi "स्टोरेज इंजन %s को लॉग टेबल्स के लिए इस्तेमाल नहीं किया जा सकता है"
spa "No se puede usar el motor de almacenaje %s para tablas de historial (log)"
ER_BAD_LOG_STATEMENT
chi "如果启用日志记录,则无法'%s'日志表"
eng "You cannot '%s' a log table if logging is enabled"
ger "Sie können eine Logtabelle nicht '%s', wenn Loggen angeschaltet ist"
+ geo "თუ ჟურნალი ჩართულია, მის ცხრილზე '%s' ოპერაციას ვერ შეასრულებთ"
spa "No puede '%s' una tabla de historial (log) cuando se encuentra activado el llevar historial (log)"
ER_CANT_RENAME_LOG_TABLE
chi "无法重命名'%s'。启用日志记录时,重命名日志表必须重命名两个表:日志表到存档表,另一个表返回'%s'"
@@ -7054,6 +7619,7 @@ ER_WRONG_PARAMETERS_TO_STORED_FCT 42000
chi "呼叫中的参数不正确为存储函数'%-.192s'"
eng "Incorrect parameters in the call to stored function '%-.192s'"
ger "Falsche Parameter beim Aufruf der gespeicherten Funktion '%-.192s'"
+ geo "არასწორი პარამეტრები დამახსოვრებული ფუნქციის გამოძახებისას '%-.192s'"
spa "Parámetros incorrectos en la llamada a función almacenada '%-.192s'"
ER_NATIVE_FCT_NAME_COLLISION
chi "此功能'%-.192s'具有与本机函数相同的名称"
@@ -7070,6 +7636,7 @@ ER_DUP_ENTRY_WITH_KEY_NAME 23000 S1009
est "Kattuv väärtus '%-.64T' võtmele '%-.192s'"
fre "Duplicata du champ '%-.64T' pour la clef '%-.192s'"
ger "Doppelter Eintrag '%-.64T' für Schlüssel '%-.192s'"
+ geo "დუბლირებული ჩანაწერი '%-.64T' გასაღებისთვის '%-.192s'"
greek "Διπλή εγγραφή '%-.64T' για το κλειδί '%-.192s'"
hun "Duplikalt bejegyzes '%-.64T' a '%-.192s' kulcs szerint"
ita "Valore duplicato '%-.64T' per la chiave '%-.192s'"
@@ -7091,6 +7658,7 @@ ER_BINLOG_PURGE_EMFILE
chi "打开太多文件,请再次执行命令"
eng "Too many files opened, please execute the command again"
ger "Zu viele offene Dateien, bitte führen Sie den Befehl noch einmal aus"
+ geo "გახსნილია მეტისმეტად ბევრი ფაილი. ბრძანება თავიდან გაუშვით"
spa "Demasiados ficheros/archivos abiertos. Por favor, ejecute el comando otra vez"
ER_EVENT_CANNOT_CREATE_IN_THE_PAST
chi "事件执行时间在过去,并ON COMPLETION NOT PRESERVE。创建后,事件立即丢弃"
@@ -7106,11 +7674,13 @@ ER_SLAVE_INCIDENT
chi "事件%s发生在master上。消息:%-.64s"
eng "The incident %s occurred on the master. Message: %-.64s"
ger "Der Vorfall %s passierte auf dem Master. Meldung: %-.64s"
+ geo "მთავარი სერვერის ინციდენტი %s. შეტყობინება: %-.64s"
spa "Ha ocurrido un incidente %s en el maestro (master). Mensaje: %-.64s"
ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT
chi "表对某些现有值没有分区"
eng "Table has no partition for some existing values"
ger "Tabelle hat für einige bestehende Werte keine Partition"
+ geo "ზოგიერთი არსებული მნიშვნელობისთვის ცხრილს დანაყოფი არ გააჩნია"
spa "La tabla no tiene partición para algunos valores existentes"
ER_BINLOG_UNSAFE_STATEMENT
chi "自从BINLOG_FORMAT =STATEMENT以来,使用语句格式写入二进制日志的不安全语句。%s."
@@ -7122,81 +7692,97 @@ ER_SLAVE_FATAL_ERROR
chi "致命错误:%s"
eng "Fatal error: %s"
ger "Fataler Fehler: %s"
+ geo "ფატალური შეცდომა: %s"
spa "Error fatal: %s"
ER_SLAVE_RELAY_LOG_READ_FAILURE
chi "relay日志读取失败:%s"
eng "Relay log read failure: %s"
ger "Relaylog-Lesefehler: %s"
+ geo "RelayLog-ის წაკითხვის შეცდომა: %s"
spa "Fallo de lectura en historial (log) de reenvío: %s"
ER_SLAVE_RELAY_LOG_WRITE_FAILURE
chi "relay日志写入失败:%s"
eng "Relay log write failure: %s"
ger "Relaylog-Schreibfehler: %s"
+ geo "RelayLog-ში ჩაწერის შეცდომა: %s"
spa "Fallo de grabación en historial (log) de reenvío: %s"
ER_SLAVE_CREATE_EVENT_FAILURE
chi "无法创建%s"
eng "Failed to create %s"
ger "Erzeugen von %s fehlgeschlagen"
+ geo "%s-ის შექმნის შეცდომა"
hindi "%s को बनाने मैं असफल रहे"
spa "Fallo al crear %s"
ER_SLAVE_MASTER_COM_FAILURE
chi "Master命令%s失败:%s"
eng "Master command %s failed: %s"
ger "Master-Befehl %s fehlgeschlagen: %s"
+ geo "მთავარი სერვერის ბრძანება %s ავარიულად დასრულდა: %s"
spa "El comando maestro (master) %s ha fallado: %s"
ER_BINLOG_LOGGING_IMPOSSIBLE
chi "二进制记录不可能。消息:%s"
eng "Binary logging not possible. Message: %s"
ger "Binärlogging nicht möglich. Meldung: %s"
+ geo "ბინარული ჟურნალი შეუძლებელია. შეტყობინება: %s"
spa "No es posible llevar historial (log) binario. Mensaje: %s"
ER_VIEW_NO_CREATION_CTX
chi "View%`s.%`s没有创建上下文"
eng "View %`s.%`s has no creation context"
ger "View %`s.%`s hat keinen Erzeugungskontext"
+ geo "ხედს %`s.%`s შექმნის კონტექსტი არ გააჩნია"
spa "La vista %`s.%`s no tiene contexto de creación"
ER_VIEW_INVALID_CREATION_CTX
chi "Creation View%`s.%`s的上下文无效"
eng "Creation context of view %`s.%`s is invalid"
ger "Erzeugungskontext des Views%`s.%`s ist ungültig"
+ geo "ხედის %`s.%`s შექნის კონტექსტი არასწორია"
spa "El contexto de creación de la vista %`s.%`s es inválido"
ER_SR_INVALID_CREATION_CTX
chi "存储例程%`s.%`s的创建上下文无效"
eng "Creation context of stored routine %`s.%`s is invalid"
ger "Erzeugungskontext der gespeicherten Routine%`s.%`s ist ungültig"
+ geo "დამახსოვრებული ქვეპროგრამის %`s.%`s შექმნის კონტექსტი არასწორია"
spa "El contexto de creación de la rutina almacenada %`s.%`s es inválido"
ER_TRG_CORRUPTED_FILE
chi "表的trg文件损坏了。%`s.%`s"
eng "Corrupted TRG file for table %`s.%`s"
ger "Beschädigte TRG-Datei für Tabelle %`s.%`s"
+ geo "დაზიანებული TRG ფაილი ცხრილისთვის %`s.%`s"
spa "Fichero/archivo TRG estropeado para la tabla %`s.%`s`"
ER_TRG_NO_CREATION_CTX
chi "表%`s.%`s的触发器没有创建上下文"
eng "Triggers for table %`s.%`s have no creation context"
ger "Trigger für Tabelle %`s.%`s haben keinen Erzeugungskontext"
+ geo "ტრიგერებს ცხრილისთვის %`s.%`s შექმნის კონტექსტი არ გააჩნიათ"
spa "Los disparadores para la tabla %`s.%`s no tienen contexto de creación"
ER_TRG_INVALID_CREATION_CTX
chi "触发表%`s.%`s的创建上下文无效"
eng "Trigger creation context of table %`s.%`s is invalid"
ger "Trigger-Erzeugungskontext der Tabelle %`s.%`s ist ungültig"
+ geo "ტრიგერის შექმნის კონტექსტი ცხრილისთვის %`s.%`s არასწორია"
spa "El contexto de creación del disparador de la tabla %`s.%`s es inválido"
ER_EVENT_INVALID_CREATION_CTX
chi "事件%`s.%`s的创建上下文无效"
eng "Creation context of event %`s.%`s is invalid"
ger "Erzeugungskontext des Events %`s.%`s ist ungültig"
+ geo "მოვლენის %`s.%`s შექმნის კონტექსტი არასწორია"
spa "El contexto de creación del evento %`s.%`s es inválido"
ER_TRG_CANT_OPEN_TABLE
chi "无法打开触发%`s.%`s的表"
eng "Cannot open table for trigger %`s.%`s"
ger "Kann Tabelle für den Trigger %`s.%`s nicht öffnen"
+ geo "ცხრილის გახსნის შეცდომა ტრიგერისთვის %`s.%`s"
spa "No puedo abrir tabla para disparador %`s.%`s"
ER_CANT_CREATE_SROUTINE
chi "无法创建存储过程%`s。检查警告"
eng "Cannot create stored routine %`s. Check warnings"
ger "Kann gespeicherte Routine %`s nicht erzeugen. Beachten Sie die Warnungen"
+ geo "შენახული ქვეპროგრამის %`s შექმნის შეცდომა. შეამოწმეთ გაფრთხილებები"
spa "No puedo crear rutina alnacenada %`s. Revise los avisos"
ER_UNUSED_11
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერ უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT
chi "类型%s的Binlog语句未在格式描述binlog语句之前"
@@ -7207,59 +7793,71 @@ ER_SLAVE_CORRUPT_EVENT
chi "检测到损坏的复制事件"
eng "Corrupted replication event was detected"
ger "Beschädigtes Replikationsereignis entdeckt"
+ geo "აღმოჩენილია დაზიანებული რეპლიკაციის მოვლენა"
spa "Se ha detectado un evento de réplica estropeado"
ER_LOAD_DATA_INVALID_COLUMN
chi "LOAD DATA中的列引用(%-.64s)无效"
eng "Invalid column reference (%-.64s) in LOAD DATA"
ger "Ungültige Spaltenreferenz (%-.64s) bei LOAD DATA"
+ geo "არასწორი სვეტის მიმართვა (%-.64s) LOAD DATA-ში"
spa "Referencia inválida a columna (%-.64s) en LOAD DATA"
ER_LOG_PURGE_NO_FILE
chi "未找到清除的log%s"
eng "Being purged log %s was not found"
ger "Zu bereinigende Logdatei %s wurde nicht gefunden"
+ geo "წასაშლელი ჟურნალი %s ვერ ვიპოვე"
spa "No ha sido hallado historial (log) %s siendo purgado"
ER_XA_RBTIMEOUT XA106
chi "XA_RBTIMEOUT:交易分支回滚:花了太久了"
eng "XA_RBTIMEOUT: Transaction branch was rolled back: took too long"
ger "XA_RBTIMEOUT: Transaktionszweig wurde zurückgerollt: Zeitüberschreitung"
+ geo "XA_RBTIMEOUT: ტრანზაქციის ბრენჩი დაბრუნდა: მეტისმეტად დიდი დრო დასჭირდა"
spa "XA_RBTIMEOUT: Rama de transacción ha sido retrocedida (rolled back): transcurrido demasiado tiempo"
ER_XA_RBDEADLOCK XA102
chi "XA_RBDEADLOCK:交易分支回滚:检测到死锁"
eng "XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected"
ger "XA_RBDEADLOCK: Transaktionszweig wurde zurückgerollt: Deadlock entdeckt"
+ geo "XA_RBDEADLOCK: ტრანაქციის ბრენჩი დაბრუნდა: აღმოჩენილია უსასრულო ციკლი"
spa "XA_RBDEADLOCK: Rama de transacción ha dido retrocedida (rolled back): se ha detectado estancamiento (deadlock)"
ER_NEED_REPREPARE
chi "prepared statement需要重新准备"
eng "Prepared statement needs to be re-prepared"
ger "Vorbereitete Anweisungen müssen noch einmal vorbereitet werden"
+ geo "საჭიროა მომზადებული გამოსახულება თავიდან მოამზადოთ"
spa "Sentencia preparada necesita volver a ser preparada"
ER_DELAYED_NOT_SUPPORTED
chi "表'%-.192s'不支持延迟选项"
eng "DELAYED option not supported for table '%-.192s'"
ger "Die DELAYED-Option wird für Tabelle '%-.192s' nicht unterstützt"
+ geo "ცხრილისთვის '%-.192s' პარამეტრი DELAYED მხარდაჭერილი არაა"
spa "Opción DELAYED no soportada para la tabla '%-.192s'"
WARN_NO_MASTER_INFO
eng "There is no master connection '%.*s'"
ger "Die Master-Info-Struktur existiert nicht '%.*s'"
+ geo "მთავარ სერვერთან მიერთება '%.*s' არ არსებობს"
spa "No existe conexión maestra '%.*s'"
WARN_OPTION_IGNORED
eng "<%-.64s> option ignored"
ger "Option <%-.64s> ignoriert"
+ geo "პარამეტრი <%-.64s> იგნორირებულია"
spa "Opción <%-.64s> ignorada"
ER_PLUGIN_DELETE_BUILTIN
chi "内置插件无法删除"
eng "Built-in plugins cannot be deleted"
ger "Eingebaute Plugins können nicht gelöscht werden"
+ geo "ჩაშენებული დამატებების წაშლა შეუძლებელია"
spa "No se pueden borrar los enchufes (plugins) internos"
WARN_PLUGIN_BUSY
chi "插件很忙,将在关机时卸载"
eng "Plugin is busy and will be uninstalled on shutdown"
ger "Plugin wird verwendet und wird erst beim Herunterfahren deinstalliert"
+ geo "დამატება დაკავებულია და გამორთვისას წაიშლება"
spa "El enchufe (plugin) está ocupado y será desinstalado cuando se apague"
ER_VARIABLE_IS_READONLY
chi "%s变量'%s'是只读的。使用set%s付值"
eng "%s variable '%s' is read-only. Use SET %s to assign the value"
ger "%s Variable '%s' ist nur lesbar. Benutzen Sie SET %s, um einen Wert zuzuweisen"
+ geo "%s ცვლადი '%s' მხოლოდ წაკითხვადია. მნიშვნელობის მისანიჭებლად გამოიყენეთ ბრძანება SET %s"
spa "%s variable '%s' es de sólo lectura. Use SET %s para asignar el valor"
ER_WARN_ENGINE_TRANSACTION_ROLLBACK
chi "存储引擎%s不支持此语句的回滚。交易回滚并必须重新启动"
@@ -7270,41 +7868,49 @@ ER_SLAVE_HEARTBEAT_FAILURE
chi "意外的master心跳数据:%s"
eng "Unexpected master's heartbeat data: %s"
ger "Unerwartete Daten vom Heartbeat des Masters: %s"
+ geo "მთავარი სერვერის გულისცემის მოულოდნელი მონაცემები: %s"
spa "Datos inesperados de latido (heartbeat) de maestro (master): %s"
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
chi "心跳周期的请求值是负的或超过允许的最大值(%u秒)"
eng "The requested value for the heartbeat period is either negative or exceeds the maximum allowed (%u seconds)"
+ geo "გულისცემის პერიოდის მოთოხვნილი მნიშვნელობა ან უარყოფითა, ან მაქსიმალურ დაშვებულ მნიშვნელობას (%u წამი) აჭარბებს"
spa "El valor requerido para el período de latido o es negativo o excede al máximo permitido (%u segundos)"
ER_UNUSED_14
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერ უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_CONFLICT_FN_PARSE_ERROR
chi "解析冲突功能时出错。消息:%-.64s"
eng "Error in parsing conflict function. Message: %-.64s"
ger "Fehler beim Parsen einer Konflikt-Funktion. Meldung: %-.64s"
+ geo "კონფლიქტური ფუნქციის დამუშავების შეცდომა. შეტყობინება: %-.64s"
spa "Error al analizar función de conflicto. Mensaje: %-.64s"
ER_EXCEPTIONS_WRITE_ERROR
chi "写入异常表失败。消息:%-.128s"
eng "Write to exceptions table failed. Message: %-.128s""
ger "Schreiben in Ausnahme-Tabelle fehlgeschlagen. Meldung: %-.128s""
+ geo "გამონაკლისების ცხრილში ჩაწერის შეცდომა. შეტყობინება: %-.128s""
spa "Ha fallado el grabar en tabla de excepciones. Mensaje: %-.128s""
ER_TOO_LONG_TABLE_COMMENT
chi "表格备注'%-.64s'太长(max =%u)"
eng "Comment for table '%-.64s' is too long (max = %u)"
ger "Kommentar für Tabelle '%-.64s' ist zu lang (max = %u)"
+ geo "კომენტარი ცხრილისთვის '%-.64s' ძალიან გრძელია (მაქს. = %u)"
por "Comentário para a tabela '%-.64s' é longo demais (max = %u)"
spa "El comentario para tabla '%-.64s' es demasiado largo (máx = %u)"
ER_TOO_LONG_FIELD_COMMENT
chi "字段'%-.64s'太长(max =%u)"
eng "Comment for field '%-.64s' is too long (max = %u)"
ger "Kommentar für Feld '%-.64s' ist zu lang (max = %u)"
+ geo "კომენტარი ველისთვის '%-.64s' ძალიან გრძელია (მაქს. = %u)"
por "Comentário para o campo '%-.64s' é longo demais (max = %u)"
spa "El comentario para el campo '%-.64s' es demasiado largo (máx = %u)"
ER_FUNC_INEXISTENT_NAME_COLLISION 42000
chi "FUNCTION %s不存在。在参考手册中查看“函数名称解析”部分"
eng "FUNCTION %s does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual"
ger "FUNCTION %s existiert nicht. Erläuterungen im Abschnitt 'Function Name Parsing and Resolution' im Referenzhandbuch"
+ geo "FUNCTION %s არ არსებობს. სახელმძღვანელოში 'ფუნქციის სახელის დამუშავების და გადაჭრის' სექცია მოძებნეთ"
spa "La FUNCTION %s no existe. Revise la sección de 'Function Name Parsing and Resolution' en el Manual de Referencia"
# When updating these, please update EXPLAIN_FILENAME_MAX_EXTRA_LENGTH in
# sql_table.h with the new maximal additional length for explain_filename.
@@ -7312,6 +7918,7 @@ ER_DATABASE_NAME
chi "数据库"
eng "Database"
ger "Datenbank"
+ geo "მონაცემთა ბაზა"
hindi "डेटाबेस"
spa "Base de datos"
swe "Databas"
@@ -7319,6 +7926,7 @@ ER_TABLE_NAME
chi "表"
eng "Table"
ger "Tabelle"
+ geo "ცხრილი"
hindi "टेबल"
spa "Tabla"
swe "Tabell"
@@ -7326,6 +7934,7 @@ ER_PARTITION_NAME
chi "分区"
eng "Partition"
ger "Partition"
+ geo "დანაყოფი"
hindi "पार्टीशन"
spa "Partición"
swe "Partition"
@@ -7333,6 +7942,7 @@ ER_SUBPARTITION_NAME
chi "下分区"
eng "Subpartition"
ger "Unterpartition"
+ geo "ქვედანაყოფი"
hindi "सब-पार्टीशन"
spa "Subpartición"
swe "Subpartition"
@@ -7340,6 +7950,7 @@ ER_TEMPORARY_NAME
chi "暂时的"
eng "Temporary"
ger "Temporär"
+ geo "დროებითი"
hindi "अस्थायी"
spa "Temporaria"
swe "Temporär"
@@ -7347,38 +7958,45 @@ ER_RENAMED_NAME
chi "重命名"
eng "Renamed"
ger "Umbenannt"
+ geo "გადარქმეულია"
spa "Renombrado"
swe "Namnändrad"
ER_TOO_MANY_CONCURRENT_TRXS
chi "“太多并发交易"
eng "Too many active concurrent transactions"
ger "Zu viele aktive simultane Transaktionen"
+ geo "გაშვებულია მეტისმეტად ბევრი აქტიური ერთდროული ტრანზაქცია"
spa "Demasiadas transacciones concurrentes activas"
WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED
chi "非ASCII分隔符参数不完全支持"
eng "Non-ASCII separator arguments are not fully supported"
ger "Nicht-ASCII-Trennargumente werden nicht vollständig unterstützt"
+ geo "არა-ASCII გამყოფი არგუმენტები სრულად მხარდაჭერილი არაა"
spa "Los argumentos con separador No ASCII no están completamente soportados"
ER_DEBUG_SYNC_TIMEOUT
chi "调试同步点等待超时"
eng "debug sync point wait timed out"
ger "Debug Sync Point Wartezeit überschritten"
+ geo "გამართვის სინქრონიზაციის წერტილის მოლოდინის დრო ამოიწურა"
spa "agotado tiempo de espera de punto de sincronización de depuración"
ER_DEBUG_SYNC_HIT_LIMIT
chi "调试同步点限制达到"
eng "debug sync point hit limit reached"
ger "Debug Sync Point Hit Limit erreicht"
+ geo "მიღწეულია სინქრონიზაციის წერტილის ზღვარი"
spa "alcanzado límite de punto de sincronización de depuración"
ER_DUP_SIGNAL_SET 42000
chi "重复条件信息项'%s'"
eng "Duplicate condition information item '%s'"
ger "Informationselement '%s' für Duplikatbedingung"
+ geo "დუბლირებული პირობის ინფორმაცია ჩანაწერზე '%s'"
spa "Duplicado elemento de información de condición '%s'"
# Note that the SQLSTATE is not 01000, it is provided by SIGNAL/RESIGNAL
ER_SIGNAL_WARN 01000
chi "未处理用户定义的警告条件"
eng "Unhandled user-defined warning condition"
ger "Unbehandelte benutzerdefinierte Warnbedingung"
+ geo "დაუმუშავებელი მომხმარებლის მიერ აღწერილი გაფრთხილების პირობა"
spa "Condición de aviso definida por usuario sin manejar"
# Note that the SQLSTATE is not 02000, it is provided by SIGNAL/RESIGNAL
ER_SIGNAL_NOT_FOUND 02000
@@ -7396,26 +8014,31 @@ ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER 0K000
chi "RESIGNAL处理程序不活跃"
eng "RESIGNAL when handler not active"
ger "RESIGNAL bei nicht aktivem Handler"
+ geo "RESIGNAL როცა დამმუშავებელი აქტიური არაა"
spa "RESIGNAL cuando el manejador no activo"
ER_SIGNAL_BAD_CONDITION_TYPE
chi "SIGNAL/RESIGNAL只能使用SQLState定义的条件"
eng "SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE"
ger "SIGNAL/RESIGNAL kann nur mit einer Bedingung (CONDITION) benutzt werden, die bei SQLSTATE definiert wurde"
+ geo "SIGNAL/RESIGNAL-ს მხოლოდ SQLSTATE-ით აღწერილი CONDITION-ის გამოყენება შეუძლია"
spa "SIGNAL/RESIGNAL sólo pueden usar una CONDITION definida mediante SQLSTATE"
WARN_COND_ITEM_TRUNCATED
chi "数据被截断为条件项目'%s'"
eng "Data truncated for condition item '%s'"
ger "Daten gekürzt für Bedingungselement '%s'"
+ geo "პირობის ჩანაწერისთვის '%s' მონაცემები წაკვეთილია"
spa "Datos truncados para elemento de condición '%s'"
ER_COND_ITEM_TOO_LONG
chi "条件项目'%s'的数据太长"
eng "Data too long for condition item '%s'"
ger "Daten zu lang für Bedingungselement '%s'"
+ geo "პირობის ჩანაწერისთვის '%s' მონაცემები ძალიან გრძელია"
spa "Datos demasiados largos para elemento de condición '%s'"
ER_UNKNOWN_LOCALE
chi "未知区域设置:'%-.64s'"
eng "Unknown locale: '%-.64s'"
ger "Unbekannte Locale: '%-.64s'"
+ geo "უცნობი ლოკალი: '%-.64s'"
spa "Localización (locale) desconocida: '%-.64s'"
ER_SLAVE_IGNORE_SERVER_IDS
chi "请求的服务器ID%d与SLAVE启动选项--replicate-same-server-id冲突"
@@ -7445,16 +8068,19 @@ ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
chi "'%-.192s'中的太多字段"
eng "Too many fields in '%-.192s'"
ger "Zu viele Felder in '%-.192s'"
+ geo "მეტისმეტად ბევრი ველი '%-.192s'-ში"
spa "Demasiados campos en '%-.192s'"
ER_MAXVALUE_IN_VALUES_IN
chi "不能在VALUES IN使用MAXVALUE"
eng "Cannot use MAXVALUE as value in VALUES IN"
ger "MAXVALUE kann nicht als Wert in VALUES IN verwendet werden"
+ geo "MAXVALUE-ის გამოყენება VALUES IN-ში შეუძლებელია"
spa "No puedo usar MAXVALUE como valor en VALUES IN"
ER_TOO_MANY_VALUES_ERROR
chi "这种类型不能有多个值%-.64s 分区"
eng "Cannot have more than one value for this type of %-.64s partitioning"
ger "Für den Partionierungstyp %-.64s darf es nicht mehr als einen Wert geben"
+ geo "%-.64s ტიპის დაყოფისთვის ერთზე მეტი მნიშვნელობა ვერ გექნებათ"
spa "No puedo tener más de un valor para este tipo de particionamiento %-.64s"
ER_ROW_SINGLE_PARTITION_FIELD_ERROR
chi "仅允许的多字段列分区的VALUES IN的行表达式"
@@ -7465,47 +8091,58 @@ ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
chi "字段'%-.192s'类型不允许为此类型的分区类型"
eng "Field '%-.192s' is of a not allowed type for this type of partitioning"
ger "Feld '%-.192s' ist für diese Art von Partitionierung von einem nicht zulässigen Typ"
+ geo "ველი %-.192s ამ ტიპის დაყოფისთვის დაუშვებელია"
spa "El campo '%-.192s' es de un tipo no permitido para este tipo de particionado"
ER_PARTITION_FIELDS_TOO_LONG
chi "分区字段的总长度太大"
eng "The total length of the partitioning fields is too large"
ger "Die Gesamtlänge der Partitionsfelder ist zu groß"
+ geo "დაყოფის ველების ჯამური სიგრძე მეტისმეტეად დიდია"
spa "El tamaño total de los campos de particionado es demasiado grande"
ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE
chi "无法执行语句:由于引擎不能支持行和语句,因此无法写入二进制日志"
eng "Cannot execute statement: impossible to write to binary log since both row-incapable engines and statement-incapable engines are involved"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ რეჟიმში ჩაწერა შეუძლებელია, რადგან ჩარეულია ორივე, მწკრივობის შეუძლებელი და გამოსახულების შეუძლებელი ძრავები"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que ambos motores de fila-incapaz y de sentencia-incapaz están involucrados"
ER_BINLOG_ROW_MODE_AND_STMT_ENGINE
chi "无法执行语句:由于BINLOG_FORMAT =ROW和至少一个表使用存储引擎限制为基于语句的日志记录,因此无法写入二进制日志"
eng "Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = ROW and at least one table uses a storage engine limited to statement-based logging"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან BINLOG_FORMAT = ROW და სულ ცოტა ერთი ცხრილი იყენებს შენახვის ძრავას, რომელიც გამოსახულების-ჟურნალითაა შეზღუდული"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que BINLOG_FORMAT = ROW y al menos una tabla utiliza motor de almacenaje limitado a historiales basados en sentencia"
ER_BINLOG_UNSAFE_AND_STMT_ENGINE
chi "无法执行语句:由于语句不安全,无法写入二进制日志,存储引擎仅限于基于语句的日志记录,而BINLOG_FORMAT = MIXED。%s."
eng "Cannot execute statement: impossible to write to binary log since statement is unsafe, storage engine is limited to statement-based logging, and BINLOG_FORMAT = MIXED. %s"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან გამოსახულება უსაფრთხო არაა, საცავის ძრავა შეზღუდულია გამოსახულებებზე-დაფუძნებულ ჟურნალზე და BINLOG_FORMAT = MIXED. %s"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que la sentencia no es segura, el motor de almacenaje está limitado a historial basado en sentencia y BINLOG_FORMAT = MIXED. %s"
ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE
chi "无法执行语句:由于语句以行格式,至少一个表使用基于语句的日志记录的存储引擎,因此无法写入二进制日志。"
eng "Cannot execute statement: impossible to write to binary log since statement is in row format and at least one table uses a storage engine limited to statement-based logging"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან გამოსახულება მწკრივის ფორმატშია და სულ ცოტა ერთი ცხრილი იყენებს საცავის ძრავას, რომელიც გამოსახულებაზე ბაზირებული ჟურნალითაა შეზღუდული"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que la sentencia está en un formato de fila y al menos una tabla utiliza un motor de almacenaje limitado a historial basado en sentencia"
ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
chi "无法执行语句:由于BINLOG_FORMAT = STATEMENT,并且至少一个表使用存储引擎限制为基于行的日志记录,因此无法写入二进制日志。%s"
eng "Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging.%s"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან BINLOG_FORMAT = STATEMENT და სულ ცოტა ერთი ცხრილი იყენებს საცავის ძრავას, რომელიც მწკრივებზე ბაზირებული ჟურნალითაა შეზღუდული. %s"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que BINLOG_FORMAT = STATEMENT y al menos una tabla utilizan un motor de almacenaje limitado a historial basado en fila. %s"
ER_BINLOG_ROW_INJECTION_AND_STMT_MODE
chi "无法执行语句:由于语句的正常格式和BINLOG_FORMAT = STATEMENT,因此无法写入二进制日志"
eng "Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან გამოსახულება მწკრივის ფორმატშია და BINLOG_FORMAT = STATEMENT"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que la sentencia está en formato de fila y BINLOG_FORMAT = STATEMENT"
ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE
chi "无法执行语句:由于涉及多个引擎并且至少有一个引擎是自记录的,因此无法写入二进制日志。"
eng "Cannot execute statement: impossible to write to binary log since more than one engine is involved and at least one engine is self-logging"
+ geo "გამოსახულების შესრულება შეუძლებელია: ბინარულ ჟურნალში ჩაწერა შეუძლებელია, რადგან ჩარეულია ერთზე მეტი ძრავა და სულ ცოტა ერთი ძრავა ჟურნალს თავისთან ინახავს"
spa "No puedo ejecutar sentencia: imposible grabar historial (log) binario ya que hay más de un motor involucrado y al menos un motor usa auto-historial"
ER_BINLOG_UNSAFE_LIMIT
chi "该语句不安全,因为它使用限制子句。这不安全,因为所包含的一组行无法预测"
eng "The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის LIMIT პირობას იყენებს. ეს უსაფრთხო არაა, რადგან მწკრივების ნაკრები, რომელიც ჩასმული იქნება, წინასწარ უცნობია"
spa "La sentencia no es segura debido a usar una cláusula LIMIT. No es segura porque el conjunto incluido de filas no se puede predecir"
ER_BINLOG_UNSAFE_INSERT_DELAYED
chi "该声明不安全,因为它使用插入延迟。这是不安全的,因为无法预测插入行的时间"
eng "The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის INSERT DELAYED-ს იყენებს. ეს უსაფრთხო არაა, რადგან წინასწარ უცნობია, რამდენჯერ მოხდება მწკრივების ჩასმა"
spa "La sentencia no es segura debido a usar una INSERT DELAYED. No es segura porque los momentos en que las filas han de insertarse no se pueden predecir"
ER_BINLOG_UNSAFE_SYSTEM_TABLE
chi "该声明不安全,因为它使用常规日志,慢查询日志或performance_schema表。这是不安全的,因为系统表可能在slave上不同"
@@ -7514,10 +8151,12 @@ ER_BINLOG_UNSAFE_SYSTEM_TABLE
ER_BINLOG_UNSAFE_AUTOINC_COLUMNS
chi "语句不安全,因为它调用了插入AUTO_INCREMENT列的触发器或存储函数。插入的值无法正确记录"
eng "Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის უშვებს ტრიგერს ან დამახსოვრებულ ფუნქციას, რომელიც AUTO_INCREMENT სვეტში ამატებს. ჩასული მნიშვნელობების ჟურნალში სწორად ჩაწერა შეუძლებელია"
spa "La sentencia no es segura debido a invocar un disparador o una función almacenada que inserta una columna de AUTO_INCREMENT. No se puede llevar historial correcto de Los valores insertados".
ER_BINLOG_UNSAFE_UDF
chi "语句不安全,因为它使用了一个可能在从设备上返回相同值的UDF"
eng "Statement is unsafe because it uses a UDF which may not return the same value on the slave"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის იყენებს UDF-ს, რომელმაც შეიძლება დამორჩილებულ სერვერებზე იგივე მნიშვნელობა არ დააბრუნოს"
spa "La sentencia no es segura porque usa un UDF que puede no devolver el mismo valor en el esclavo"
ER_BINLOG_UNSAFE_SYSTEM_VARIABLE
chi "语句不安全,因为它使用的系统变量可能在从站上具有不同的值"
@@ -7526,37 +8165,45 @@ ER_BINLOG_UNSAFE_SYSTEM_VARIABLE
ER_BINLOG_UNSAFE_SYSTEM_FUNCTION
chi "语句不安全,因为它使用系统函数可能在从站上返回不同的值"
eng "Statement is unsafe because it uses a system function that may return a different value on the slave"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის იყენებს სისტემურ ფუნქციას, რომელმაც შეიძლება დამორჩილებულ სერვერებზე იგივე მნიშვნელობა არ დააბრუნოს"
spa "La sentencia no es segura porque usa una función de sistema que puede devolver un valor diferente en el esclavo"
ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS
chi "语句不安全,因为它在访问同一事务中访问事务表后访问非事务性表"
eng "Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction"
+ geo "გამოსახულება უსაფრთხო არაა, რადგან ის ერთი ტრანზაქციიდან არატრანზაქციულ და ტრანზაქციულ ცხრილებს ერთდროულად მიმართავს"
spa "La sentencia no es segura porque accede a una tabla no transaccional tras acceder a una transaccional dentro de la misma transacción"
ER_MESSAGE_AND_STATEMENT
chi "%s.语句:%s"
eng "%s. Statement: %s"
+ geo "%s. გამოსახულება: %s"
spa "%s. Sentencia: %s"
ER_SLAVE_CONVERSION_FAILED
chi "列%d表'%-.192s.%-.192s'无法从'%-.50s'类型为'%-.50s'"
eng "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.50s' to type '%-.50s'"
+ geo "სვეტის %d ცხრილიდან '%-.192s.%-.192s' გადაყვანა ტიპიდან '%-.50s' ტიპში '%-.50s' შეუძლებელია"
spa "La columna %d de la tabla '%-.192s.%-.192s' no puede ser convertida desde el tipo '%-.50s' al tipo '%-.50s'"
ER_SLAVE_CANT_CREATE_CONVERSION
chi "无法为表创建转换表'%-.192s.%-.192s'"
eng "Can't create conversion table for table '%-.192s.%-.192s'"
+ geo "ცხრილისთვის '%-.192s.%-.192s' გადაყვანის ცხრილის შექმნა შეუძლებელია"
spa "No puedo crear tabla de conversión para la tabla '%-.192s.%-.192s'"
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT
chi "无法在事务中修改@@session.binlog_format"
eng "Cannot modify @@session.binlog_format inside a transaction"
+ geo "@@session.binlog_format-ის შეცვლა ტრანზაქციის შიგნიდან შეუძლებელია"
spa "No puedo modificar @@session.binlog_format dentro de una transacción"
ER_PATH_LENGTH
chi "指定%.64T的路径太长了"
eng "The path specified for %.64T is too long"
+ geo "%.64T-სთვის მითითებული ბილიკი მეტისმეტად გრძელია"
hindi "%.64T के लिए निर्दिष्ट पथ बहुत लंबा है"
spa "La ruta especificada para %.64T es demasiado larga"
ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT
chi "'%s'被弃用,将在将来的版本中删除"
eng "'%s' is deprecated and will be removed in a future release"
ger "'%s' ist veraltet und wird in einer zukünftigen Version entfernt werden"
+ geo "'%s' მოძველებულია და მომავალ ვერსიებში წაიშლება"
spa "'%s' está obsoleto y será quitada en una entrega futura"
ER_WRONG_NATIVE_TABLE_STRUCTURE
chi "本机表'%-.64s'。'%-.64s'具有错误的结构"
@@ -7565,28 +8212,34 @@ ER_WRONG_NATIVE_TABLE_STRUCTURE
ER_WRONG_PERFSCHEMA_USAGE
chi "performance_schema使用无效"
eng "Invalid performance_schema usage"
+ geo "performance_schema-ის არასწორი გამოყენება"
hindi "performance_schema का अवैध उपयोग"
spa "Uso inválido de performance_schema"
ER_WARN_I_S_SKIPPED_TABLE
chi "表'%s'.'%s'由于并发DDL语句正在修改其定义,因此跳过"
eng "Table '%s'.'%s' was skipped since its definition is being modified by concurrent DDL statement"
+ geo "ცხრილი '%s'.'%s' გამოტოვებულია, რადგან მისი აღწერა ერთდროული DDL გამოსახულების მიერ იცვლება"
spa "La tabla '%s'.'%s' fue saltada ya que su definición está siendo modificada por la sentencia DDL concurrente"
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT
chi "无法在交易事务中修改@@session.binlog_direct_non_transactional_updates"
eng "Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction"
+ geo "@@session.binlog_direct_non_transactional_updates-ის ტრანზაქციის შიგნიდან შეცვლა შეუძლებელია"
spa "No puedo modificar @@session.binlog_direct_non_transactional_updates dentro de una transacción"
ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT
chi "无法在存储的函数或触发器内更改Binlog Direct标志"
eng "Cannot change the binlog direct flag inside a stored function or trigger"
+ geo "binlog-ის direct ალმის დამახსოვრებული ფუნქციის ან ტრიგერის შიგნიდან შეცვლა შეუძლებელია"
spa "No puedo cambiar la bandera directa de binlog dentro de una función almacenada o de un disparador"
ER_SPATIAL_MUST_HAVE_GEOM_COL 42000
chi "空间索引可以仅包含几何类型列"
eng "A SPATIAL index may only contain a geometrical type column"
ger "Ein raumbezogener Index (SPATIAL) darf nur Spalten geometrischen Typs enthalten"
+ geo "SPATIAL ტიპის ინდექსი მხოლოდ გეომეტრიული ტიპის სვეტს შეიძლება შეიცავდეს"
spa "Un índice SPATIAL sólo puede contener una columna de tipo geométrico"
ER_TOO_LONG_INDEX_COMMENT
chi "索引评论'%-.64s'太长(max =%lu)"
eng "Comment for index '%-.64s' is too long (max = %lu)"
+ geo "კომენტარი ინდექსისთვის '%-.64s' ძალიან გრძელია (მაქს. = %lu)"
spa "El comentario para el índice '%-.64s' es demasiado largo (máx = %lu)"
ER_LOCK_ABORTED
chi "由于待处理的独家锁,等待锁被中止"
@@ -7595,10 +8248,12 @@ ER_LOCK_ABORTED
ER_DATA_OUT_OF_RANGE 22003
chi "%s值超出'%s'范围"
eng "%s value is out of range in '%s'"
+ geo "%s-ის მნიშვნელობა '%s'-ში დიაპაზონს გარეთაა"
spa "%s valor se encuentra fuera de rango '%s'"
ER_WRONG_SPVAR_TYPE_IN_LIMIT
chi "基于非整数类型的基于LIMIT子句的变量"
eng "A variable of a non-integer based type in LIMIT clause"
+ geo "LIMIT პირობაში ცვლადი არამთელი ტიპისაა"
spa "Una variable de tipo basado en no entero en cláusula LIMIT"
ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE
chi "混合声明中的自记录和非自动记录引擎是不安全的"
@@ -7611,20 +8266,24 @@ ER_BINLOG_UNSAFE_MIXED_STATEMENT
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
chi "无法修改事务中的@@sessient.sql_log_bin"
eng "Cannot modify @@session.sql_log_bin inside a transaction"
+ geo "@@session.sql_log_bin-ის ტრანზაქციის შიგნით შეცვლა შეუძლებელია"
spa "No puedo modificar @@session.sql_log_bin dentro de una transacción"
ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN
chi "无法在存储的函数或触发器内更改SQL_LOG_BIN"
eng "Cannot change the sql_log_bin inside a stored function or trigger"
+ geo "sql_log_bin-ის შეცვლა დამახსოვრებული ფუნქციის და ტრიგერის შიგნით შეუძლებელია"
spa "No puedo cambiar sql_log_bin dentro de una función almacenada o disparador"
ER_FAILED_READ_FROM_PAR_FILE
chi "无法从.par文件中读取"
eng "Failed to read from the .par file"
+ geo ".par ფაილიდან წაკითხვის შეცდომა"
hindi ".par फ़ाइल से पढ़ने में असफल रहे"
spa "No pude leer desde fichero/archivo .par"
swe "Misslyckades läsa från .par filen"
ER_VALUES_IS_NOT_INT_TYPE_ERROR
chi "分区的值'%-.64s'必须具有类型INT"
eng "VALUES value for partition '%-.64s' must have type INT"
+ geo "VALUES-ის მნიშვნელობა დანაყოფისთვის '%-.64s' INT ტიპის უნდა იყოს"
spa "El valor VALUES para la partición '%-.64s' debe de tener el tipo INT"
swe "Värden i VALUES för partition '%-.64s' måste ha typen INT"
ER_ACCESS_DENIED_NO_PASSWORD_ERROR 28000
@@ -7635,6 +8294,7 @@ ER_ACCESS_DENIED_NO_PASSWORD_ERROR 28000
est "Ligipääs keelatud kasutajale '%s'@'%s'"
fre "Accès refusé pour l'utilisateur: '%s'@'%s'"
ger "Benutzer '%s'@'%s' hat keine Zugriffsberechtigung"
+ geo "მომხმარებლისთვის '%s'@'%s' წვდომა აკრძალულია"
greek "Δεν επιτέρεται η πρόσβαση στο χρήστη: '%s'@'%s'"
hindi "यूज़र '%s'@'%s' को अनुमति नहीं है"
hun "A(z) '%s'@'%s' felhasznalo szamara tiltott eleres"
@@ -7655,11 +8315,13 @@ ER_ACCESS_DENIED_NO_PASSWORD_ERROR 28000
ER_SET_PASSWORD_AUTH_PLUGIN
chi "通过%s插件验证的用户忽略SET PASSWORD"
eng "SET PASSWORD is ignored for users authenticating via %s plugin"
+ geo "მომხმარებლებისთვის, რომლებიც ავთენტიკაციას %s დამატებით გადიან, SET PASSWORD იგნორირებულია"
spa "SET PASSWORD no tiene significado para usuarios que se autentican vía enchufe (plugin) %s"
ER_GRANT_PLUGIN_USER_EXISTS
chi "由于用户%-.*s已经存在,GRANT IDENTIFIED WITH授权是非法的"
eng "GRANT with IDENTIFIED WITH is illegal because the user %-.*s already exists"
+ geo "ბრძანება GRANT პარამეტრით IDENTIFIED WITH დაუშვებელია, რადგან მოხმარებელი %-.*s უკვე არსებობს"
spa "GRANT con IDENTIFIED WITH es ilegal porque el usuario %-.*s ya existe"
ER_TRUNCATE_ILLEGAL_FK 42000
@@ -7670,11 +8332,13 @@ ER_TRUNCATE_ILLEGAL_FK 42000
ER_PLUGIN_IS_PERMANENT
chi "插件'%s'是force_plus_permanent,无法卸载"
eng "Plugin '%s' is force_plus_permanent and can not be unloaded"
+ geo "დამატება '%s'-ი force_plus_permanent ტიპისაა და მისი გამოტვირთვა შეუძლებელია"
spa "El enchufe (plugin) '%s' está force_plus_permanent y no puede ser descargado"
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN
chi "心跳期的要求值小于1毫秒。该值重置为0,这意味着心跳将有效地禁用"
eng "The requested value for the heartbeat period is less than 1 millisecond. The value is reset to 0, meaning that heartbeating will effectively be disabled"
+ geo "გულისცემის პერიოდის მოთხოვნილი მნიშვნელობა 1 მილიწამზე ნაკლებია. მნიშვნელობა ნულს გაუტოლდა, რაც ნიშნავს, რომ გულისცემა გამორთულია"
spa "El valor de requerimiento para el período de latido es menor de 1 milisegundo. El valor se vuelve a poner a 0, indicando que el latido será efectivamente desactivado"
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX
@@ -7701,31 +8365,37 @@ ER_TABLE_NEEDS_REBUILD
WARN_OPTION_BELOW_LIMIT
chi "'%s'的值应该不小于'%s'的值"
eng "The value of '%s' should be no less than the value of '%s'"
+ geo "'%s'-ის მნიშვნელობა '%s'-ის მნიშვნელობაზე ნაკლები არ უნდა იყოს"
spa "El valor de '%s' debería de ser no menor que el valor de '%s'"
ER_INDEX_COLUMN_TOO_LONG
chi "索引列太大。最大列大小为%lu字节"
eng "Index column size too large. The maximum column size is %lu bytes"
+ geo "ინდექსის სვეტის ზომა ძალიან დიდია. სვეტის მაქსიმალური ზომაა %lu ბაიტი"
spa "El tamaño de índice de columna es demasiado grande. El tamaño máximo de columna es de %lu bytes"
ER_ERROR_IN_TRIGGER_BODY
chi "触发器'%-.64s'内存在错误:'%-.256s'"
eng "Trigger '%-.64s' has an error in its body: '%-.256s'"
+ geo "შეცდომა ტრიგერის ('%-.64s') სხეულში: '%-.256s'"
spa "El disparador '%-.64s' tiene una error en su cuerpo: '%-.256s'"
ER_ERROR_IN_UNKNOWN_TRIGGER_BODY
chi "未知触发器内存在错误:'%-.256s'"
eng "Unknown trigger has an error in its body: '%-.256s'"
+ geo "შეცდომა უცნობი ტრიგერის სხეულში: '%-.256s'"
spa "El disparador desconocido tiene un error en su cuerpo: '%-.256s'"
ER_INDEX_CORRUPT
chi "索引%s已损坏"
eng "Index %s is corrupted"
+ geo "ინდექსი %s დაზიანებულია"
spa "El índice %s está estropeado"
ER_UNDO_RECORD_TOO_BIG
chi "撤消日志记录太大"
eng "Undo log record is too big"
+ geo "დაბრუნების ჟურნალის ჩანაწერი მეტისმეტად დიდია"
spa "El registro de historial (log) para deshacer es demasiado grande"
ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT
@@ -7761,11 +8431,13 @@ ER_BINLOG_UNSAFE_UPDATE_IGNORE
ER_UNUSED_15
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერასდროს უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_UNUSED_16
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერასდროს უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT
@@ -7786,6 +8458,7 @@ ER_BINLOG_UNSAFE_INSERT_TWO_KEYS
ER_UNUSED_28
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ამას ვერასდროს უნდა ხედავდეთ"
spa "Nunca debería vd de ver esto"
ER_VERS_NOT_ALLOWED
@@ -7804,6 +8477,7 @@ ER_CANNOT_LOAD_FROM_TABLE_V2
chi "不能从加载%s.%s。表可能损坏了"
eng "Cannot load from %s.%s. The table is probably corrupted"
ger "Kann %s.%s nicht einlesen. Tabelle ist wahrscheinlich beschädigt"
+ geo "%s.%s-დან ჩატვირთვის პრობლემა. ალბათ ცხრილი დაზიანებულია"
spa "No puedo cargar desde %s.%s. La tabla está probablemente estropeada"
ER_MASTER_DELAY_VALUE_OUT_OF_RANGE
@@ -7923,6 +8597,7 @@ ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE
ER_MTS_FEATURE_IS_NOT_SUPPORTED
chi "%s不支持多线程从模式。%s."
eng "%s is not supported in multi-threaded slave mode. %s"
+ geo "დამორჩილებული სერვერის მრავალკანადიან რეჟიმში %s მხარდაჭერილი არაა. %s"
spa "%s no se soporta en modo esclavo multi-hilo (thread). %s"
ER_MTS_UPDATED_DBS_GREATER_MAX
chi "修改的数据库的数量超过了最大%d;数据库名称不会包含在Replication事件元数据中"
@@ -7934,16 +8609,19 @@ ER_MTS_CANT_PARALLEL
spa "No puedo ejecutar el grupo de eventos actual en modo paralelo. Encontrado evento %s, nombre de historial (log) de reenvío %s, posición %s que previene la ejecución de este grupo de eventos en modo paralelo. Motivo: %s"
ER_MTS_INCONSISTENT_DATA
eng "%s"
+ geo "%s"
ER_FULLTEXT_NOT_SUPPORTED_WITH_PARTITIONING
chi "分区表不支持FullText索引"
eng "FULLTEXT index is not supported for partitioned tables"
+ geo "დაყოფილ ცხრილებზე FULLTEXT ინდექსი მხარდაჭერილი არაა"
spa "El índice FULLTEXT no está soportado para tablas particionadas"
swe "FULLTEXT index stöds ej för partitionerade tabeller"
ER_DA_INVALID_CONDITION_NUMBER 35000
chi "无效条件号"
eng "Invalid condition number"
+ geo "პირობის არასწორი ნომერი"
por "Número de condição inválido"
spa "Número inválido de condición"
@@ -7979,11 +8657,13 @@ ER_SQLTHREAD_WITH_SECURE_SLAVE
ER_TABLE_HAS_NO_FT
chi "该表没有全文索引来支持此查询"
eng "The table does not have FULLTEXT index to support this query"
+ geo "ამ მოთხოვნის მხარდასაჭერად ცხრილს FULLTEXT ინდექსი არ გააჩნია"
spa "La tabla no tiene índice FULLTEXT que soporte esta consulta (query)"
ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER
chi "无法在存储的函数或触发器中设置系统变量%.200s"
eng "The system variable %.200s cannot be set in stored functions or triggers"
+ geo "სისტემური ცვლადის %.200s მნიშვნელობას დამახსოვრებული ფუნქციებიდან და ტრიგერებიდან ვერ დააყენებთ"
spa "La variable de sistema %.200s no se puede poner en funciones almacenadas o disparadores"
ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION
@@ -8029,6 +8709,7 @@ ER_MALFORMED_GTID_SET_ENCODING
ER_MALFORMED_GTID_SPECIFICATION
chi "畸形GTID规范'%.200s'"
eng "Malformed GTID specification '%.200s'"
+ geo "GTID-ის არასწორი სპეციფიკაცია '%.200s'"
spa "GTID malformado especificación '%.200s'"
ER_GNO_EXHAUSTED
@@ -8114,6 +8795,7 @@ ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID
ER_UNKNOWN_EXPLAIN_FORMAT
chi "未知%s格式名称:'%s'"
eng "Unknown %s format name: '%s'"
+ geo "უცნობი ფორმატის სახელი ბრძანებისთვის %s: '%s'"
rus "Неизвестное имя формата команды %s: '%s'"
spa "Nombre de formato %s desconocido: '%s'"
@@ -8160,11 +8842,13 @@ ER_INNODB_ONLINE_LOG_TOO_BIG
ER_UNKNOWN_ALTER_ALGORITHM
chi "未知算法'%s'"
eng "Unknown ALGORITHM '%s'"
+ geo "უცნობი ALGORITHM '%s'"
spa "ALGORITHM desconocido '%s'"
ER_UNKNOWN_ALTER_LOCK
chi "未知锁定类型'%s'"
eng "Unknown LOCK type '%s'"
+ geo "უცნობი LOCK-ის ტიპი '%s'"
spa "Tipo de LOCK desconocido '%s'"
ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS
@@ -8196,11 +8880,13 @@ ER_SLAVE_SILENT_RETRY_TRANSACTION
ER_UNUSED_22
chi "你永远不应该看到它"
eng "You should never see it"
+ geo "ეს არასდროს უნდა დაინახოთ"
spa "Nunca debería vd de ver esto"
ER_TABLE_SCHEMA_MISMATCH
chi "架构不匹配(%s)"
eng "Schema mismatch (%s)"
+ geo "სქემა არ ემთხვევა (%s)"
spa "Esquema no coincide (%s)"
ER_TABLE_IN_SYSTEM_TABLESPACE
@@ -8211,11 +8897,13 @@ ER_TABLE_IN_SYSTEM_TABLESPACE
ER_IO_READ_ERROR
chi "IO读取错误:(%lu,%s)%s"
eng "IO Read error: (%lu, %s) %s"
+ geo "IO წაკითხვის შეცდომა: (%lu, %s) %s"
spa "Error de Lectura de E/S: (%lu, %s) %s"
ER_IO_WRITE_ERROR
chi "IO写错错误:(%lu,%s)%s"
eng "IO Write error: (%lu, %s) %s"
+ geo "IO ჩაწერის შეცდომა: (%lu, %s) %s"
spa "Error de Escritura de E/S: (%lu, %s) %s"
ER_TABLESPACE_MISSING
@@ -8236,16 +8924,19 @@ ER_TABLESPACE_DISCARDED
ER_INTERNAL_ERROR
chi "内部错误:%-.192s"
eng "Internal error: %-.192s"
+ geo "შიდა შეცდომა: %-.192s"
spa "Error interno: %-.192s"
ER_INNODB_IMPORT_ERROR
chi "ALTER TABLE '%-.192s' IMPORT TABLESPACE 失败,错误%lu:'%s'"
eng "ALTER TABLE '%-.192s' IMPORT TABLESPACE failed with error %lu : '%s'"
+ geo "ALTER TABLE '%-.192s' IMPORT TABLESPACE დასრულდა შეცდომით %lu : '%s'"
spa "ALTER TABLE '%-.192s' IMPORT TABLESPACE ha fallado con error %lu : '%s'"
ER_INNODB_INDEX_CORRUPT
chi "索引损坏:%s"
eng "Index corrupt: %s"
+ geo "ინდექსი დაზიანებულია: %s"
spa "Índice corrupto: %s"
ER_INVALID_YEAR_COLUMN_LENGTH
@@ -8256,12 +8947,14 @@ ER_INVALID_YEAR_COLUMN_LENGTH
ER_NOT_VALID_PASSWORD
eng "Your password does not satisfy the current policy requirements (%s)"
+ geo "თქვენი პაროლი მიმდინარე პოლიტიკის მოთხოვნებს არ აკმაყოფილებს (%s)"
ukr "Ваш пароль не відповідає поточним правилам (%s)"
ER_MUST_CHANGE_PASSWORD
bgn "Трябва първо да си смените паролата със SET PASSWORD за да можете да изпълните тази команда"
chi "您必须在执行此语句之前设置密码"
eng "You must SET PASSWORD before executing this statement"
+ geo "ამ გამოსახულების გაშვებამდე SET PASSWORD უნდა გაუშვათ"
rum "Trebuie sa iti schimbi parola folosind SET PASSWORD inainte de a executa aceasta comanda"
spa "Debe vd de poner SET PASSWORD antes de ejecutar esta sentencia"
@@ -8341,11 +9034,13 @@ ER_FK_CANNOT_DELETE_PARENT
ER_MALFORMED_PACKET
chi "畸形通信包"
eng "Malformed communication packet"
+ geo "კომუნიკაციის არასწორი პაკეტი"
spa "Paquete de comunicación malformado"
ER_READ_ONLY_MODE
chi "以只读模式运行"
eng "Running in read-only mode"
+ geo "გაშვებულია მხოლოდ-წაკითხვის რეჟიმში"
spa "Ejecutando em modo sólo-lectura"
ER_GTID_NEXT_TYPE_UNDEFINED_GROUP
@@ -8376,11 +9071,13 @@ ER_CANT_SET_GTID_PURGED_WHEN_OWNED_GTIDS_IS_NOT_EMPTY
ER_GTID_PURGED_WAS_CHANGED
chi "GTID_PURGED从'%s'更改为'%s'"
eng "GTID_PURGED was changed from '%s' to '%s'"
+ geo "GTID_PURGED შეიცვალა '%s'-დან '%s'-ზე"
spa "GTID_PURGED se cambió de '%s' a '%s'"
ER_GTID_EXECUTED_WAS_CHANGED
chi "GTID_EXECUTE从'%s'更改为'%s'"
eng "GTID_EXECUTED was changed from '%s' to '%s'"
+ geo "GTID_EXECUTED შეიცვალა '%s'-დან '%s'-ზე"
spa "GTID_EXECUTED se cambió de '%s' a '%s'"
ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
@@ -8466,6 +9163,7 @@ ER_DUP_UNKNOWN_IN_INDEX 23000
est "Kattuv väärtus võtmele '%-.192s'"
fre "Duplicata du champ pour la clef '%-.192s'"
ger "Doppelter Eintrag für Schlüssel '%-.192s'"
+ geo "დუბლირებული ჩანაწერი გასაღებისთვის '%-.192s'"
greek "Διπλή εγγραφή για το κλειδί '%-.192s'"
hun "Duplikalt bejegyzes a '%-.192s' kulcs szerint"
ita "Valore duplicato per la chiave '%-.192s'"
@@ -8743,6 +9441,7 @@ ER_CONNECTION_ALREADY_EXISTS
ER_MASTER_LOG_PREFIX
chi "Master'%.*s':"
eng "Master '%.*s': "
+ geo "მთავარი სერვერი '%.*s': "
spa "Maestro (master) '%.*s': "
ER_CANT_START_STOP_SLAVE
chi "不能%sSLAVE'%.*s'"
@@ -8751,10 +9450,12 @@ ER_CANT_START_STOP_SLAVE
ER_SLAVE_STARTED
chi "SLAVE '%.*s'开始了"
eng "SLAVE '%.*s' started"
+ geo "SLAVE '%.*s' გაეშვა"
spa "ESCLAVO '%.*s' arrancado"
ER_SLAVE_STOPPED
chi "slave'%.*s'停止了"
eng "SLAVE '%.*s' stopped"
+ geo "SLAVE '%.*s' გაჩერდა"
spa "ESCLAVO '%.*s' parado"
ER_SQL_DISCOVER_ERROR
chi "引擎%s无法发现表%`-.192s.%`-.192s,'%s'"
@@ -8780,6 +9481,7 @@ ER_GTID_OPEN_TABLE_FAILED
chi "未能打开%s.%s"
eng "Failed to open %s.%s"
ger "Öffnen von %s.%s fehlgeschlagen"
+ geo "%s.%s-ის გახსნის შეცდომა"
spa "No pude abrir %s.%s"
ER_GTID_POSITION_NOT_FOUND_IN_BINLOG
chi "连接从站请求从GTID%u-%u-%llu开始,这不在Master的Binlog中"
@@ -8833,6 +9535,7 @@ ER_NO_SUCH_QUERY
chi "未知查询ID:%lld"
eng "Unknown query id: %lld"
ger "Unbekannte Abfrage-ID: %lld"
+ geo "უცნობი მოთხოვნის id: %lld"
hindi "अज्ञात क्वेरी ID: %lld"
rus "Неизвестный номер запроса: %lld"
spa "Id desconocido de consulta (query): %lld"
@@ -8843,6 +9546,7 @@ ER_BAD_BASE64_DATA
ER_INVALID_ROLE OP000
chi "无效的角色规范%`s"
eng "Invalid role specification %`s"
+ geo "არასწორი როლის აღწერა %`s"
hindi "अमान्य रोल विनिर्देश %`s"
rum "Rolul %`s este invalid"
spa "Especificación inválida de rol %`s"
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fa2b144e06f..bae35cd3264 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -47,6 +47,8 @@
#include "sql_prepare.h"
#include "sql_statistics.h"
#include "sql_cte.h"
+#include "sql_update.h" // class Sql_cmd_update
+#include "sql_delete.h" // class Sql_cmd_delete
#include <m_ctype.h>
#include <my_dir.h>
#include <hash.h>
@@ -1106,7 +1108,11 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
(table->table equal to 0) and right names is in current TABLE_LIST
object.
*/
- if (table->table)
+ if (table->table &&
+ thd->lex->sql_command != SQLCOM_UPDATE &&
+ thd->lex->sql_command != SQLCOM_UPDATE_MULTI &&
+ thd->lex->sql_command != SQLCOM_DELETE &&
+ thd->lex->sql_command != SQLCOM_DELETE_MULTI)
{
/* All MyISAMMRG children are plain MyISAM tables. */
DBUG_ASSERT(table->table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
@@ -1190,16 +1196,42 @@ retry:
We come here for queries of type:
INSERT INTO t1 (SELECT tmp.a FROM (select * FROM t1) as tmp);
- Try to fix by materializing the derived table
+ Try to fix by materializing the derived table if one can't do without it.
*/
TABLE_LIST *derived= res->belong_to_derived;
if (derived->is_merged_derived() && !derived->derived->is_excluded())
{
- DBUG_PRINT("info",
+ bool materialize= true;
+ if (thd->lex->sql_command == SQLCOM_UPDATE)
+ {
+ Sql_cmd_update *cmd= (Sql_cmd_update *) (thd->lex->m_sql_cmd);
+ if (cmd->is_multitable() || derived->derived->outer_select())
+ materialize= false;
+ else if (!cmd->processing_as_multitable_update_prohibited(thd))
+ {
+ cmd->set_as_multitable();
+ materialize= false;
+ }
+ }
+ else if (thd->lex->sql_command == SQLCOM_DELETE)
+ {
+ Sql_cmd_delete *cmd= (Sql_cmd_delete *) (thd->lex->m_sql_cmd);
+ if (cmd->is_multitable() || derived->derived->outer_select())
+ materialize= false;
+ else if (!cmd->processing_as_multitable_delete_prohibited(thd))
+ {
+ cmd->set_as_multitable();
+ materialize= false;
+ }
+ }
+ if (materialize)
+ {
+ DBUG_PRINT("info",
("convert merged to materialization to resolve the conflict"));
- derived->change_refs_to_fields();
- derived->set_materialized_derived();
- goto retry;
+ derived->change_refs_to_fields();
+ derived->set_materialized_derived();
+ goto retry;
+ }
}
}
DBUG_RETURN(res);
@@ -4733,7 +4765,6 @@ restart:
if (tbl->file->ha_table_flags() & HA_CAN_MULTISTEP_MERGE)
{
/* MERGE tables need to access parent and child TABLE_LISTs. */
- DBUG_ASSERT(tbl->pos_in_table_list == tables);
if (tbl->file->extra(HA_EXTRA_ATTACH_CHILDREN))
{
error= TRUE;
@@ -5698,6 +5729,28 @@ bool open_tables_only_view_structure(THD *thd, TABLE_LIST *table_list,
}
+bool open_tables_for_query(THD *thd, TABLE_LIST *tables,
+ uint *table_count, uint flags,
+ DML_prelocking_strategy *prelocking_strategy)
+{
+ MDL_savepoint mdl_savepoint = thd->mdl_context.mdl_savepoint();
+
+ DBUG_ASSERT(tables == thd->lex->query_tables);
+
+ if (open_tables(thd, &tables, table_count,
+ thd->stmt_arena->is_stmt_prepare() ? MYSQL_OPEN_FORCE_SHARED_MDL : 0,
+ prelocking_strategy))
+ {
+ close_thread_tables(thd);
+ /* Don't keep locks for a failed statement. */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+ return true;
+ }
+
+ return false;
+}
+
+
/*
Mark all real tables in the list as free for reuse.
@@ -7841,6 +7894,9 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
if (!(*with_wild))
DBUG_RETURN(0);
+ if (!fields.elements)
+ DBUG_RETURN(0);
+
/*
Don't use arena if we are not in prepared statements or stored procedures
For PS/SP we have to use arena to remember the changes
@@ -8111,7 +8167,7 @@ bool setup_table_attributes(THD *thd, TABLE_LIST *table_list,
uint &tablenr)
{
TABLE *table= table_list->table;
- if (table)
+ if (table && !table->pos_in_table_list)
table->pos_in_table_list= table_list;
if (first_select_table && table_list->top_table() == first_select_table)
{
@@ -8126,7 +8182,6 @@ bool setup_table_attributes(THD *thd, TABLE_LIST *table_list,
}
else if (table)
{
- table->pos_in_table_list= table_list;
setup_table_map(table, table_list, tablenr);
if (table_list->process_index_hints(table))
diff --git a/sql/sql_base.h b/sql/sql_base.h
index 6e17d8214ad..f4a49d99125 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -28,6 +28,7 @@ struct Name_resolution_context;
class Open_table_context;
class Open_tables_state;
class Prelocking_strategy;
+class DML_prelocking_strategy;
struct TABLE_LIST;
class THD;
struct handlerton;
@@ -288,6 +289,9 @@ bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags,
bool open_tables_only_view_structure(THD *thd, TABLE_LIST *tables,
bool can_deadlock);
bool open_and_lock_internal_tables(TABLE *table, bool lock);
+bool open_tables_for_query(THD *thd, TABLE_LIST *tables,
+ uint *table_count, uint flags,
+ DML_prelocking_strategy *prelocking_strategy);
bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags);
int decide_logging_format(THD *thd, TABLE_LIST *tables);
void close_thread_table(THD *thd, TABLE **table_ptr);
@@ -430,6 +434,17 @@ public:
};
+
+class Multiupdate_prelocking_strategy : public DML_prelocking_strategy
+{
+ bool done;
+ bool has_prelocking_list;
+public:
+ void reset(THD *thd);
+ bool handle_end(THD *thd);
+};
+
+
/**
A strategy for prelocking algorithm to be used for LOCK TABLES
statement.
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 089b9ce5dbe..3021055d4b6 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5284,7 +5284,7 @@ private:
bool use_temporary_table(TABLE *table, TABLE **out_table);
void close_temporary_table(TABLE *table);
bool log_events_and_free_tmp_shares();
- void free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table);
+ bool free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table);
void free_temporary_table(TABLE *table);
bool lock_temporary_tables();
void unlock_temporary_tables();
@@ -7133,6 +7133,7 @@ public:
enum_duplicates handle_duplicates, bool ignore);
~multi_update();
bool init(THD *thd);
+ bool init_for_single_table(THD *thd);
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);
bool initialize_tables (JOIN *join);
@@ -7141,6 +7142,8 @@ public:
bool send_eof();
inline ha_rows num_found() const { return found; }
inline ha_rows num_updated() const { return updated; }
+ inline void set_found (ha_rows n) { found= n; }
+ inline void set_updated (ha_rows n) { updated= n; }
virtual void abort_result_set();
void update_used_tables();
void prepare_to_read_rows();
diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h
index 2623b3703d3..985be776713 100644
--- a/sql/sql_cmd.h
+++ b/sql/sql_cmd.h
@@ -118,6 +118,7 @@ enum enum_sql_command {
SQLCOM_END
};
+struct TABLE_LIST;
class Storage_engine_name
{
@@ -144,6 +145,8 @@ public:
};
+class Prepared_statement;
+
/**
@class Sql_cmd - Representation of an SQL command.
@@ -180,10 +183,28 @@ public:
virtual enum_sql_command sql_command_code() const = 0;
/**
- Execute this SQL statement.
- @param thd the current thread.
- @retval false on success.
- @retval true on error
+ @brief Check whether the statement has been prepared
+ @returns true if this statement is prepared, false otherwise
+ */
+ bool is_prepared() const { return m_prepared; }
+
+ /**
+ @brief Prepare this SQL statement
+ @param thd global context the processed statement
+ @returns false if success, true if error
+ */
+ virtual bool prepare(THD *thd)
+ {
+ /* Default behavior for a statement is to have no preparation code. */
+ DBUG_ASSERT(!is_prepared());
+ set_prepared();
+ return false;
+ }
+
+ /**
+ @brief Execute this SQL statement
+ @param thd global context the processed statement
+ @returns false if success, true if error
*/
virtual bool execute(THD *thd) = 0;
@@ -192,8 +213,40 @@ public:
return NULL;
}
+ /**
+ @brief Set the owning prepared statement
+ */
+ void set_owner(Prepared_statement *stmt) { m_owner = stmt; }
+
+ /**
+ @breaf Get the owning prepared statement
+ */
+ Prepared_statement *get_owner() { return m_owner; }
+
+ /**
+ @brief Check whether this command is a DML statement
+ @return true if SQL command is a DML statement, false otherwise
+ */
+ virtual bool is_dml() const { return false; }
+
+ /**
+ @brief Unprepare prepared statement for the command
+ @param thd global context of the processed statement
+
+ @notes
+ Temporary function used to "unprepare" a prepared statement after
+ preparation, so that a subsequent execute statement will reprepare it.
+ This is done because UNIT::cleanup() will un-resolve all resolved QBs.
+ */
+ virtual void unprepare(THD *thd)
+ {
+ DBUG_ASSERT(is_prepared());
+ m_prepared = false;
+ }
+
protected:
- Sql_cmd() = default;
+ Sql_cmd() : m_prepared(false), m_owner(nullptr)
+ {}
virtual ~Sql_cmd()
{
@@ -203,10 +256,152 @@ protected:
simply destroyed instead.
Do not rely on the destructor for any cleanup.
*/
- DBUG_ASSERT(FALSE);
+ DBUG_ASSERT(false);
}
+
+ /**
+ @brief Set this statement as prepared
+ */
+ void set_prepared() { m_prepared = true; }
+
+ private:
+ /* True when statement has been prepared */
+ bool m_prepared;
+ /* Owning prepared statement, nullptr if not prepared */
+ Prepared_statement *m_owner;
+
};
+struct LEX;
+class select_result;
+class Prelocking_strategy;
+class DML_prelocking_strategy;
+class Protocol;
+
+/**
+ @class Sql_cmd_dml - derivative abstract class used for DML statements
+
+ This class is a class derived from Sql_cmd used when processing such
+ data manipulation commands as SELECT, INSERT, UPDATE, DELETE and others
+ that operate over some tables.
+ After the parser phase all these commands are supposed to be processed
+ by the same schema:
+ - precheck of the access rights is performed for the used tables
+ - the used tables are opened
+ - context analysis phase is performed for the statement
+ - the used tables are locked
+ - the statement is optimized and executed
+ - clean-up is performed for the statement.
+ This schema is reflected in the function Sql_cmd_dml::execute() that
+ uses Sql_cmd_dml::prepare is the statement has not been prepared yet.
+ Precheck of the access right, context analysis are specific for statements
+ of a certain type. That's why the methods implementing this operations are
+ declared as abstract in this class.
+
+ @note
+ Currently this class is used only for UPDATE and DELETE commands.
+*/
+class Sql_cmd_dml : public Sql_cmd
+{
+public:
+
+ /**
+ @brief Check whether the statement changes the contents of used tables
+ @return true if this is data change statement, false otherwise
+ */
+ virtual bool is_data_change_stmt() const { return true; }
+
+ /**
+ @brief Perform context analysis of the statement
+ @param thd global context the processed statement
+ @returns false on success, true on error
+ */
+ virtual bool prepare(THD *thd);
+
+ /**
+ Execute the processed statement once
+ @param thd global context the processed statement
+ @returns false on success, true on error
+ */
+ virtual bool execute(THD *thd);
+
+ virtual bool is_dml() const { return true; }
+
+ select_result *get_result() { return result; }
+
+protected:
+ Sql_cmd_dml()
+ : Sql_cmd(), lex(nullptr), result(nullptr),
+ m_empty_query(false)
+ {}
+
+ /**
+ @brief Check whether query is guaranteed to return no data
+ @return true if query is guaranteed to return no data, false otherwise
+
+ @todo Also check this for the following cases:
+ - Empty source for multi-table UPDATE and DELETE.
+ - Check empty query expression for INSERT
+ */
+ bool is_empty_query() const
+ {
+ DBUG_ASSERT(is_prepared());
+ return m_empty_query;
+ }
+
+ /**
+ @brief Set statement as returning no data
+ */
+ void set_empty_query() { m_empty_query = true; }
+
+ /**
+ @brief Perform precheck of table privileges for the specific command
+ @param thd global context the processed statement
+ @returns false if success, true if false
+
+ @details
+ Check that user has some relevant privileges for all tables involved in
+ the statement, e.g. SELECT privileges for tables selected from, INSERT
+ privileges for tables inserted into, etc. This function will also populate
+ TABLE_LIST::grant with all privileges the user has for each table, which
+ is later used during checking of column privileges.
+ Note that at preparation time, views are not expanded yet. Privilege
+ checking is thus rudimentary and must be complemented with later calls to
+ SELECT_LEX::check_view_privileges().
+ The reason to call this function at such an early stage is to be able to
+ quickly reject statements for which the user obviously has insufficient
+ privileges.
+ */
+ virtual bool precheck(THD *thd) = 0;
+
+ /**
+ @brief Perform the command-specific actions of the context analysis
+ @param thd global context the processed statement
+ @returns false if success, true if error
+
+ @note
+ This function is called from prepare()
+ */
+ virtual bool prepare_inner(THD *thd) = 0;
+
+ /**
+ @brief Perform the command-specific actions of optimization and excution
+ @param thd global context the processed statement
+ @returns false on success, true on error
+ */
+ virtual bool execute_inner(THD *thd);
+
+ virtual DML_prelocking_strategy *get_dml_prelocking_strategy() = 0;
+
+ uint table_count;
+
+ protected:
+ LEX *lex; /**< Pointer to LEX for this statement */
+ select_result *result; /**< Pointer to object for handling of the result */
+ bool m_empty_query; /**< True if query will produce no rows */
+};
+
+
class Sql_cmd_show_slave_status: public Sql_cmd
{
protected:
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 0c0f05aab07..18d4b4b6af5 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -44,6 +44,9 @@
// end_read_record
#include "sql_insert.h" // fix_rownum_pointers
#include "sql_partition.h" // make_used_partitions_str
+#ifdef WITH_WSREP
+#include "wsrep_mysqld.h"
+#endif
#define MEM_STRIP_BUF_SIZE ((size_t) thd->variables.sortbuff_size)
@@ -103,7 +106,7 @@ bool Update_plan::save_explain_data_intern(MEM_ROOT *mem_root,
bool is_analyze)
{
explain->select_type= "SIMPLE";
- explain->table_name.append(&table->pos_in_table_list->alias);
+ explain->table_name.append(table->alias);
explain->impossible_where= false;
explain->no_partitions= false;
@@ -295,123 +298,85 @@ int TABLE::delete_row()
/**
- Implement DELETE SQL word.
+ @brief Special handling of single-table deletes after prepare phase
- @note Like implementations of other DDL/DML in MySQL, this function
- relies on the caller to close the thread tables. This is done in the
- end of dispatch_command().
+ @param thd global context the processed statement
+ @returns false on success, true on error
*/
-bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
- SQL_I_List<ORDER> *order_list, ha_rows limit,
- ulonglong options, select_result *result)
+bool Sql_cmd_delete::delete_from_single_table(THD *thd)
{
- bool will_batch= FALSE;
- int error, loc_error;
- TABLE *table;
- SQL_SELECT *select=0;
- SORT_INFO *file_sort= 0;
- READ_RECORD info;
- bool using_limit=limit != HA_POS_ERROR;
- bool transactional_table, safe_update, const_cond;
- bool const_cond_result;
- bool return_error= 0;
- ha_rows deleted= 0;
- bool reverse= FALSE;
- bool has_triggers= false;
- ORDER *order= (ORDER *) ((order_list && order_list->elements) ?
- order_list->first : NULL);
- SELECT_LEX *select_lex= thd->lex->first_select_lex();
- SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0;
+ int error;
+ int loc_error;
+ bool transactional_table;
+ bool const_cond;
+ bool safe_update;
+ bool const_cond_result;
+ bool return_error= 0;
+ TABLE *table;
+ SQL_SELECT *select= 0;
+ SORT_INFO *file_sort= 0;
+ READ_RECORD info;
+ ha_rows deleted= 0;
+ bool reverse= FALSE;
+ bool binlog_is_row;
killed_state killed_status= NOT_KILLED;
THD::enum_binlog_query_type query_type= THD::ROW_QUERY_TYPE;
- bool binlog_is_row;
- Explain_delete *explain;
+ bool will_batch= FALSE;
+
+ bool has_triggers= false;
+ SELECT_LEX_UNIT *unit = &lex->unit;
+ SELECT_LEX *select_lex= unit->first_select();
+ SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0;
+ TABLE_LIST *const table_list = select_lex->get_table_list();
+ ulonglong options= select_lex->options;
+ ORDER *order= select_lex->order_list.first;
+ COND *conds= select_lex->join->conds;
+ ha_rows limit= unit->lim.get_select_limit();
+ bool using_limit= limit != HA_POS_ERROR;
+
Delete_plan query_plan(thd->mem_root);
+ Explain_delete *explain;
Unique * deltempfile= NULL;
bool delete_record= false;
- bool delete_while_scanning;
+ bool delete_while_scanning= table_list->delete_while_scanning;
bool portion_of_time_through_update;
- DBUG_ENTER("mysql_delete");
+
+ DBUG_ENTER("Sql_cmd_delete::delete_single_table");
query_plan.index= MAX_KEY;
query_plan.using_filesort= FALSE;
- create_explain_query(thd->lex, thd->mem_root);
- if (open_and_lock_tables(thd, table_list, TRUE, 0))
- DBUG_RETURN(TRUE);
-
THD_STAGE_INFO(thd, stage_init_update);
const bool delete_history= table_list->vers_conditions.delete_history;
DBUG_ASSERT(!(delete_history && table_list->period_conditions.is_set()));
- if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT))
- DBUG_RETURN(TRUE);
- if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
- DBUG_RETURN(TRUE);
+ if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(1);
+ if (table_list->handle_derived(thd->lex, DT_PREPARE))
+ DBUG_RETURN(1);
+
+ table= table_list->table;
if (!table_list->single_table_updatable())
{
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
DBUG_RETURN(TRUE);
}
- if (!(table= table_list->table) || !table->is_created())
+
+ if (!table || !table->is_created())
{
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(TRUE);
}
- table->map=1;
+
query_plan.select_lex= thd->lex->first_select_lex();
query_plan.table= table;
thd->lex->promote_select_describe_flag_if_needed();
- if (mysql_prepare_delete(thd, table_list, &conds, &delete_while_scanning))
- DBUG_RETURN(TRUE);
-
- if (table_list->has_period())
- {
- if (!table_list->period_conditions.start.item->const_item()
- || !table_list->period_conditions.end.item->const_item())
- {
- my_error(ER_NOT_CONSTANT_EXPRESSION, MYF(0), "FOR PORTION OF");
- DBUG_RETURN(true);
- }
- }
-
- if (delete_history)
- table->vers_write= false;
-
- if (returning)
- (void) result->prepare(returning->item_list, NULL);
-
- if (thd->lex->current_select->first_cond_optimization)
- {
- thd->lex->current_select->save_leaf_tables(thd);
- thd->lex->current_select->first_cond_optimization= 0;
- }
- /* check ORDER BY even if it can be ignored */
- if (order)
- {
- TABLE_LIST tables;
- List<Item> fields;
- List<Item> all_fields;
-
- bzero((char*) &tables,sizeof(tables));
- tables.table = table;
- tables.alias = table_list->alias;
-
- if (select_lex->setup_ref_array(thd, order_list->elements) ||
- setup_order(thd, select_lex->ref_pointer_array, &tables,
- fields, all_fields, order))
- {
- free_underlaid_joins(thd, thd->lex->first_select_lex());
- DBUG_RETURN(TRUE);
- }
- }
-
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
if (select_lex->optimize_unflattened_subqueries(false))
DBUG_RETURN(TRUE);
@@ -1017,90 +982,6 @@ got_error:
}
-/*
- Prepare items in DELETE statement
-
- SYNOPSIS
- mysql_prepare_delete()
- thd - thread handler
- table_list - global/local table list
- conds - conditions
-
- RETURN VALUE
- FALSE OK
- TRUE error
-*/
-int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds,
- bool *delete_while_scanning)
-{
- Item *fake_conds= 0;
- SELECT_LEX *select_lex= thd->lex->first_select_lex();
- DBUG_ENTER("mysql_prepare_delete");
- List<Item> all_fields;
-
- *delete_while_scanning= true;
- thd->lex->allow_sum_func.clear_all();
- if (setup_tables_and_check_access(thd, &select_lex->context,
- &select_lex->top_join_list, table_list,
- select_lex->leaf_tables, FALSE,
- DELETE_ACL, SELECT_ACL, TRUE))
- DBUG_RETURN(TRUE);
-
- if (table_list->vers_conditions.is_set() && table_list->is_view_or_derived())
- {
- my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
- DBUG_RETURN(true);
- }
-
- if (table_list->has_period())
- {
- if (table_list->is_view_or_derived())
- {
- my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
- DBUG_RETURN(true);
- }
-
- if (select_lex->period_setup_conds(thd, table_list))
- DBUG_RETURN(true);
- }
-
- DBUG_ASSERT(table_list->table);
- // conds could be cached from previous SP call
- DBUG_ASSERT(!table_list->vers_conditions.need_setup() ||
- !*conds || thd->stmt_arena->is_stmt_execute());
- if (select_lex->vers_setup_conds(thd, table_list))
- DBUG_RETURN(TRUE);
-
- *conds= select_lex->where;
-
- if (setup_returning_fields(thd, table_list) ||
- setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
- setup_ftfuncs(select_lex))
- DBUG_RETURN(TRUE);
- if (!table_list->single_table_updatable() ||
- check_key_in_view(thd, table_list))
- {
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
- DBUG_RETURN(TRUE);
- }
-
- /*
- Application-time periods: if FOR PORTION OF ... syntax used, DELETE
- statement could issue delete_row's mixed with write_row's. This causes
- problems for myisam and corrupts table, if deleting while scanning.
- */
- if (table_list->has_period()
- || unique_table(thd, table_list, table_list->next_global, 0))
- *delete_while_scanning= false;
-
- if (select_lex->inner_refs_list.elements &&
- fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
- DBUG_RETURN(TRUE);
-
- select_lex->fix_prepare_information(thd, conds, &fake_conds);
- DBUG_RETURN(FALSE);
-}
-
/***************************************************************************
Delete multiple tables from join
@@ -1113,106 +994,6 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b)
return file->cmp_ref((const uchar*)a, (const uchar*)b);
}
-/*
- make delete specific preparation and checks after opening tables
-
- SYNOPSIS
- mysql_multi_delete_prepare()
- thd thread handler
-
- RETURN
- FALSE OK
- TRUE Error
-*/
-
-int mysql_multi_delete_prepare(THD *thd)
-{
- LEX *lex= thd->lex;
- TABLE_LIST *aux_tables= lex->auxiliary_table_list.first;
- TABLE_LIST *target_tbl;
- DBUG_ENTER("mysql_multi_delete_prepare");
-
- if (mysql_handle_derived(lex, DT_INIT))
- DBUG_RETURN(TRUE);
- if (mysql_handle_derived(lex, DT_MERGE_FOR_INSERT))
- DBUG_RETURN(TRUE);
- if (mysql_handle_derived(lex, DT_PREPARE))
- DBUG_RETURN(TRUE);
- /*
- setup_tables() need for VIEWs. JOIN::prepare() will not do it second
- time.
-
- lex->query_tables also point on local list of DELETE SELECT_LEX
- */
- if (setup_tables_and_check_access(thd,
- &thd->lex->first_select_lex()->context,
- &thd->lex->first_select_lex()->
- top_join_list,
- lex->query_tables,
- lex->first_select_lex()->leaf_tables,
- FALSE, DELETE_ACL, SELECT_ACL, FALSE))
- DBUG_RETURN(TRUE);
-
- /*
- Multi-delete can't be constructed over-union => we always have
- single SELECT on top and have to check underlying SELECTs of it
- */
- lex->first_select_lex()->set_unique_exclude();
- /* Fix tables-to-be-deleted-from list to point at opened tables */
- for (target_tbl= (TABLE_LIST*) aux_tables;
- target_tbl;
- target_tbl= target_tbl->next_local)
- {
-
- target_tbl->table= target_tbl->correspondent_table->table;
- if (target_tbl->correspondent_table->is_multitable())
- {
- my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
- target_tbl->correspondent_table->view_db.str,
- target_tbl->correspondent_table->view_name.str);
- DBUG_RETURN(TRUE);
- }
-
- if (!target_tbl->correspondent_table->single_table_updatable() ||
- check_key_in_view(thd, target_tbl->correspondent_table))
- {
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
- target_tbl->table_name.str, "DELETE");
- DBUG_RETURN(TRUE);
- }
- }
-
- for (target_tbl= (TABLE_LIST*) aux_tables;
- target_tbl;
- target_tbl= target_tbl->next_local)
- {
- /*
- Check that table from which we delete is not used somewhere
- inside subqueries/view.
- */
- {
- TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, target_tbl->correspondent_table,
- lex->query_tables, 0)))
- {
- update_non_unique_table_error(target_tbl->correspondent_table,
- "DELETE", duplicate);
- DBUG_RETURN(TRUE);
- }
- }
- }
- /*
- Reset the exclude flag to false so it doesn't interfare
- with further calls to unique_table
- */
- lex->first_select_lex()->exclude_from_table_unique_test= FALSE;
-
- if (lex->save_prep_leaf_tables())
- DBUG_RETURN(TRUE);
-
- DBUG_RETURN(FALSE);
-}
-
multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, uint num_of_tables_arg):
select_result_interceptor(thd_arg), delete_tables(dt), deleted(0), found(0),
@@ -1338,6 +1119,8 @@ multi_delete::~multi_delete()
table_being_deleted= table_being_deleted->next_local)
{
TABLE *table= table_being_deleted->table;
+ if (!table)
+ continue;
table->no_keyread=0;
table->no_cache= 0;
}
@@ -1667,3 +1450,364 @@ bool multi_delete::send_eof()
}
return 0;
}
+
+
+/**
+ @brief Remove ORDER BY from DELETE if it's used without limit clause
+*/
+
+void Sql_cmd_delete::remove_order_by_without_limit(THD *thd)
+{
+ SELECT_LEX *const select_lex = thd->lex->first_select_lex();
+ if (select_lex->order_list.elements &&
+ !select_lex->limit_params.select_limit)
+ select_lex->order_list.empty();
+}
+
+
+/**
+ @brief Check whether processing to multi-table delete is prohibited
+
+ @param thd global context the processed statement
+ @returns true if processing as multitable is prohibited, false otherwise
+
+ @todo
+ Introduce handler level flag for storage engines that would prohibit
+ such conversion for any single-table delete.
+*/
+
+bool Sql_cmd_delete::processing_as_multitable_delete_prohibited(THD *thd)
+{
+ SELECT_LEX *const select_lex = thd->lex->first_select_lex();
+ return
+ ((select_lex->order_list.elements &&
+ select_lex->limit_params.select_limit) ||
+ thd->lex->has_returning());
+}
+
+
+/**
+ @brief Perform precheck of table privileges for delete statements
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+*/
+
+bool Sql_cmd_delete::precheck(THD *thd)
+{
+ if (!multitable)
+ {
+ if (delete_precheck(thd, lex->query_tables))
+ return true;
+ }
+ else
+ {
+ if (multi_delete_precheck(thd, lex->query_tables))
+ return true;
+ }
+
+#ifdef WITH_WSREP
+ WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
+#endif
+
+ return false;
+
+#ifdef WITH_WSREP
+wsrep_error_label:
+#endif
+ return true;
+}
+
+
+/**
+ @brief Perform context analysis for delete statements
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+
+ @note
+ The main bulk of the context analysis actions for a delete statement
+ is performed by a call of JOIN::prepare().
+*/
+
+bool Sql_cmd_delete::prepare_inner(THD *thd)
+{
+ int err= 0;
+ TABLE_LIST *target_tbl;
+ JOIN *join;
+ SELECT_LEX *const select_lex = thd->lex->first_select_lex();
+ TABLE_LIST *const table_list = select_lex->get_table_list();
+ TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first;
+ ulonglong select_options= select_lex->options;
+ bool free_join= 1;
+ SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0;
+ const bool delete_history= table_list->vers_conditions.delete_history;
+ DBUG_ASSERT(!(delete_history && table_list->period_conditions.is_set()));
+
+ DBUG_ENTER("Sql_cmd_delete::prepare_inner");
+
+ (void) read_statistics_for_tables_if_needed(thd, table_list);
+
+ THD_STAGE_INFO(thd, stage_init_update);
+
+ {
+ if (mysql_handle_derived(lex, DT_INIT))
+ DBUG_RETURN(TRUE);
+ if (mysql_handle_derived(lex, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(TRUE);
+ if (mysql_handle_derived(lex, DT_PREPARE))
+ DBUG_RETURN(TRUE);
+ }
+
+ if (!(result= new (thd->mem_root) multi_delete(thd, aux_tables,
+ lex->table_count_update)))
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ table_list->delete_while_scanning= true;
+
+ if (!multitable && !table_list->single_table_updatable())
+ {
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
+ DBUG_RETURN(TRUE);
+ }
+
+ if (!multitable && (!table_list->table || !table_list->table->is_created()))
+ {
+ my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
+ table_list->view_db.str, table_list->view_name.str);
+ DBUG_RETURN(TRUE);
+ }
+
+ if (setup_tables_and_check_access(thd, &select_lex->context,
+ &select_lex->top_join_list,
+ table_list, select_lex->leaf_tables,
+ false, DELETE_ACL, SELECT_ACL, true))
+ DBUG_RETURN(TRUE);
+
+ if (setup_tables(thd, &select_lex->context, &select_lex->top_join_list,
+ table_list, select_lex->leaf_tables, false, false))
+ DBUG_RETURN(TRUE);
+
+ if (!multitable)
+ {
+ if (table_list->vers_conditions.is_set() && table_list->is_view_or_derived())
+ {
+ my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
+ DBUG_RETURN(true);
+ }
+
+ if (!multitable)
+ {
+ TABLE_LIST *update_source_table= 0;
+ if (((update_source_table=unique_table(thd, table_list,
+ table_list->next_global, 0)) ||
+ table_list->is_multitable()))
+ {
+ DBUG_ASSERT(update_source_table || table_list->view != 0);
+ if (!table_list->is_multitable() &&
+ !processing_as_multitable_delete_prohibited(thd))
+ {
+ multitable= true;
+ remove_order_by_without_limit(thd);
+ }
+ }
+ }
+
+ if (table_list->has_period())
+ {
+ if (table_list->is_view_or_derived())
+ {
+ my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
+ DBUG_RETURN(true);
+ }
+
+ if (select_lex->period_setup_conds(thd, table_list))
+ DBUG_RETURN(true);
+ }
+
+ if (select_lex->vers_setup_conds(thd, table_list))
+ DBUG_RETURN(TRUE);
+ /*
+ Application-time periods: if FOR PORTION OF ... syntax used, DELETE
+ statement could issue delete_row's mixed with write_row's. This causes
+ problems for myisam and corrupts table, if deleting while scanning.
+ */
+ if (table_list->has_period()
+ || unique_table(thd, table_list, table_list->next_global, 0))
+ table_list->delete_while_scanning= false;
+ }
+
+ {
+ if (thd->lex->describe)
+ select_options|= SELECT_DESCRIBE;
+
+ /*
+ When in EXPLAIN, delay deleting the joins so that they are still
+ available when we're producing EXPLAIN EXTENDED warning text.
+ */
+ if (select_options & SELECT_DESCRIBE)
+ free_join= 0;
+ select_options|=
+ SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE;
+
+ if (!(join= new (thd->mem_root) JOIN(thd, empty_list,
+ select_options, result)))
+ DBUG_RETURN(TRUE);
+ THD_STAGE_INFO(thd, stage_init);
+ select_lex->join= join;
+ thd->lex->used_tables=0;
+ if ((err= join->prepare(table_list, select_lex->where,
+ select_lex->order_list.elements,
+ select_lex->order_list.first,
+ false, NULL, NULL, NULL,
+ select_lex, &lex->unit)))
+
+ {
+ goto err;
+ }
+
+ if (!multitable &&
+ select_lex->sj_subselects.elements)
+ multitable= true;
+ }
+
+ if (multitable)
+ {
+ /*
+ Multi-delete can't be constructed over-union => we always have
+ single SELECT on top and have to check underlying SELECTs of it
+ */
+ lex->first_select_lex()->set_unique_exclude();
+ /* Fix tables-to-be-deleted-from list to point at opened tables */
+ for (target_tbl= (TABLE_LIST*) aux_tables;
+ target_tbl;
+ target_tbl= target_tbl->next_local)
+ {
+ target_tbl->table= target_tbl->correspondent_table->table;
+ if (target_tbl->correspondent_table->is_multitable())
+ {
+ my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
+ target_tbl->correspondent_table->view_db.str,
+ target_tbl->correspondent_table->view_name.str);
+ DBUG_RETURN(TRUE);
+ }
+
+ if (!target_tbl->correspondent_table->single_table_updatable() ||
+ check_key_in_view(thd, target_tbl->correspondent_table))
+ {
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
+ target_tbl->table_name.str, "DELETE");
+ DBUG_RETURN(TRUE);
+ }
+ }
+
+ /*
+ Reset the exclude flag to false so it doesn't interfare
+ with further calls to unique_table
+ */
+ lex->first_select_lex()->exclude_from_table_unique_test= FALSE;
+ }
+
+ if (!multitable && table_list->has_period())
+ {
+ if (!table_list->period_conditions.start.item->const_item()
+ || !table_list->period_conditions.end.item->const_item())
+ {
+ my_error(ER_NOT_CONSTANT_EXPRESSION, MYF(0), "FOR PORTION OF");
+ DBUG_RETURN(true);
+ }
+ }
+
+ if (delete_history)
+ table_list->table->vers_write= false;
+
+ if (setup_returning_fields(thd, table_list) ||
+ setup_ftfuncs(select_lex))
+ goto err;
+
+ free_join= false;
+
+ if (returning)
+ (void) result->prepare(returning->item_list, NULL);
+
+err:
+
+ if (free_join)
+ {
+ THD_STAGE_INFO(thd, stage_end);
+ err|= (int)(select_lex->cleanup());
+ DBUG_RETURN(err || thd->is_error());
+ }
+ DBUG_RETURN(err);
+
+}
+
+
+/**
+ @brief Perform optimization and execution actions needed for deletes
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+*/
+
+bool Sql_cmd_delete::execute_inner(THD *thd)
+{
+ if (!multitable)
+ {
+ if (lex->has_returning())
+ {
+ select_result *sel_result= NULL;
+ delete result;
+ /* This is DELETE ... RETURNING. It will return output to the client */
+ if (thd->lex->analyze_stmt)
+ {
+ /*
+ Actually, it is ANALYZE .. DELETE .. RETURNING. We need to produce
+ output and then discard it.
+ */
+ sel_result= new (thd->mem_root) select_send_analyze(thd);
+ save_protocol= thd->protocol;
+ thd->protocol= new Protocol_discard(thd);
+ }
+ else
+ {
+ if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd)))
+ return true;
+ }
+ result= lex->result ? lex->result : sel_result;
+ }
+ }
+
+ bool res= multitable ? Sql_cmd_dml::execute_inner(thd)
+ : delete_from_single_table(thd);
+
+ res|= thd->is_error();
+
+ if (save_protocol)
+ {
+ delete thd->protocol;
+ thd->protocol= save_protocol;
+ }
+ {
+ if (unlikely(res))
+ {
+ if (multitable)
+ result->abort_result_set();
+ }
+ else
+ {
+ if (thd->lex->describe || thd->lex->analyze_stmt)
+ res= thd->lex->explain->send_explain(thd);
+ }
+ }
+
+ if (result)
+ {
+ res= false;
+ delete result;
+ }
+
+ return res;
+}
diff --git a/sql/sql_delete.h b/sql/sql_delete.h
index 520524c72cc..ad018ed686c 100644
--- a/sql/sql_delete.h
+++ b/sql/sql_delete.h
@@ -17,6 +17,9 @@
#define SQL_DELETE_INCLUDED
#include "my_base.h" /* ha_rows */
+#include "sql_class.h" /* enum_duplicates */
+#include "sql_cmd.h" // Sql_cmd_dml
+#include "sql_base.h"
class THD;
struct TABLE_LIST;
@@ -26,10 +29,79 @@ class select_result;
typedef class Item COND;
template <typename T> class SQL_I_List;
-int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds,
- bool *delete_while_scanning);
-bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
- SQL_I_List<ORDER> *order, ha_rows rows,
- ulonglong options, select_result *result);
+/**
+ @class Sql_cmd_delete - class used for any DELETE statements
+ This class is derived from Sql_cmd_dml and contains implementations
+ for abstract virtual function of the latter such as precheck() and
+ prepare_inner(). It also overrides the implementation of execute_inner()
+ providing a special handling for single-table delete statements that
+ are not converted to multi-table delete.
+ The class provides an object of the DML_prelocking_strategy class
+ for the virtual function get_dml_prelocking_strategy().
+*/
+class Sql_cmd_delete final : public Sql_cmd_dml
+{
+public:
+ Sql_cmd_delete(bool multitable_arg)
+ : orig_multitable(multitable_arg), multitable(multitable_arg),
+ save_protocol(NULL)
+ {}
+
+ enum_sql_command sql_command_code() const override
+ {
+ return orig_multitable ? SQLCOM_DELETE_MULTI : SQLCOM_DELETE;
+ }
+
+ DML_prelocking_strategy *get_dml_prelocking_strategy()
+ {
+ return &dml_prelocking_strategy;
+ }
+
+ bool processing_as_multitable_delete_prohibited(THD *thd);
+
+ bool is_multitable() { return multitable; }
+
+ void set_as_multitable() { multitable= true; }
+
+ void remove_order_by_without_limit(THD *thd);
+
+protected:
+ /**
+ @brief Perform precheck of table privileges for delete statements
+ */
+ bool precheck(THD *thd) override;
+
+ /**
+ @brief Perform context analysis for delete statements
+ */
+ bool prepare_inner(THD *thd) override;
+
+ /**
+ @brief Perform optimization and execution actions needed for deletes
+ */
+ bool execute_inner(THD *thd) override;
+
+ private:
+ /**
+ @biefSpecial handling of single-table deletes after prepare phase
+ */
+ bool delete_from_single_table(THD *thd);
+
+ /* Original value of the 'multitable' flag set by constructor */
+ const bool orig_multitable;
+
+ /*
+ True if the statement is a multitable delete or converted to such.
+ For a single-table delete this flag is set to true if the statement
+ is supposed to be converted to multi-table delete.
+ */
+ bool multitable;
+
+ /* The prelocking strategy used when opening the used tables */
+ DML_prelocking_strategy dml_prelocking_strategy;
+
+ List<Item> empty_list; /**< auxiliary empty list used by prepare_inner() */
+ Protocol *save_protocol; /**< needed for ANALYZE .. DELETE .. RETURNING */
+};
#endif /* SQL_DELETE_INCLUDED */
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index ab16a9d0b8b..8a24d2febad 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -40,6 +40,8 @@
#ifdef WITH_WSREP
#include "mysql/service_wsrep.h"
#endif
+#include "sql_update.h" // class Sql_cmd_update
+#include "sql_delete.h" // class Sql_cmd_delete
void LEX::parse_error(uint err_number)
{
@@ -1303,6 +1305,8 @@ void LEX::start(THD *thd_arg)
wild= 0;
exchange= 0;
+ table_count_update= 0;
+
DBUG_VOID_RETURN;
}
@@ -3031,6 +3035,7 @@ void st_select_lex::init_select()
curr_tvc_name= 0;
versioned_tables= 0;
nest_flags= 0;
+ item_list_usage= MARK_COLUMNS_READ;
}
/*
@@ -3288,34 +3293,6 @@ void st_select_lex_unit::exclude_level()
}
-#if 0
-/*
- Exclude subtree of current unit from tree of SELECTs
-
- SYNOPSYS
- st_select_lex_unit::exclude_tree()
-*/
-void st_select_lex_unit::exclude_tree()
-{
- for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
- {
- // unlink current level from global SELECTs list
- if (sl->link_prev && (*sl->link_prev= sl->link_next))
- sl->link_next->link_prev= sl->link_prev;
-
- // unlink underlay levels
- for (SELECT_LEX_UNIT *u= sl->first_inner_unit(); u; u= u->next_unit())
- {
- u->exclude_level();
- }
- }
- // exclude currect unit from list of nodes
- (*prev)= next;
- if (next)
- next->prev= prev;
-}
-#endif
-
/*
st_select_lex_node::mark_as_dependent mark all st_select_lex struct from
@@ -3537,7 +3514,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
select_n_where_fields +
order_group_num +
hidden_bit_fields +
- fields_in_window_functions) * (size_t) 5;
+ fields_in_window_functions + 1) * (size_t) 5;
DBUG_ASSERT(n_elems % 5 == 0);
if (!ref_pointer_array.is_null())
{
@@ -4051,9 +4028,8 @@ bool LEX::can_use_merged()
SYNOPSIS
LEX::can_not_use_merged()
- @param no_update_or_delete Set to 1 if we can't use merge with multiple-table
- updates, like when used from
- TALE_LIST::init_derived()
+ @param forced_no_merge_for_update_delete Set to 1 if we can't use merge with
+ multiple-table updates/deletes
DESCRIPTION
Temporary table algorithm will be used on all SELECT levels for queries
@@ -4064,7 +4040,7 @@ bool LEX::can_use_merged()
TRUE - VIEWs with MERGE algorithms can be used
*/
-bool LEX::can_not_use_merged(bool no_update_or_delete)
+bool LEX::can_not_use_merged(bool forced_no_merge_for_update_delete)
{
switch (sql_command) {
case SQLCOM_CREATE_VIEW:
@@ -4078,11 +4054,29 @@ bool LEX::can_not_use_merged(bool no_update_or_delete)
return TRUE;
case SQLCOM_UPDATE_MULTI:
+ if (forced_no_merge_for_update_delete)
+ return TRUE;
+ /* Fall through */
+
+ case SQLCOM_UPDATE:
+ if (forced_no_merge_for_update_delete &&
+ (((Sql_cmd_update *) m_sql_cmd)->is_multitable() ||
+ query_tables->is_multitable()))
+ return TRUE;
+ return FALSE;
+
case SQLCOM_DELETE_MULTI:
- if (no_update_or_delete)
+ if (forced_no_merge_for_update_delete)
return TRUE;
/* Fall through */
+ case SQLCOM_DELETE:
+ if (forced_no_merge_for_update_delete &&
+ (((Sql_cmd_delete *) m_sql_cmd)->is_multitable() ||
+ query_tables->is_multitable()))
+ return TRUE;
+ return FALSE;
+
default:
return FALSE;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 2ddd40568f9..5a7fa14916f 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -37,6 +37,7 @@
#include "json_table.h" // Json_table_column
#include "sql_schema.h"
#include "table.h"
+#include "sql_class.h" // enum enum_column_usage
/* Used for flags of nesting constructs */
#define SELECT_NESTING_MAP_SIZE 64
@@ -875,6 +876,8 @@ public:
{
}
+ void set_query_result(select_result *res) { result= res; }
+
TABLE *table; /* temporary table using for appending UNION results */
select_result *result;
st_select_lex *pre_last_parse;
@@ -1007,6 +1010,7 @@ public:
bool add_fake_select_lex(THD *thd);
void init_prepare_fake_select_lex(THD *thd, bool first_execution);
+ void set_prepared() { prepared = true; }
inline bool is_prepared() { return prepared; }
bool change_result(select_result_interceptor *result,
select_result_interceptor *old_result);
@@ -1112,6 +1116,7 @@ public:
Item *prep_having;/* saved HAVING clause for prepared statement processing */
Item *cond_pushed_into_where; /* condition pushed into WHERE */
Item *cond_pushed_into_having; /* condition pushed into HAVING */
+ Item *where_cond_after_prepare;
/*
nest_levels are local to the query or VIEW,
@@ -1222,6 +1227,7 @@ public:
List<List_item> save_many_values;
List<Item> *save_insert_list;
+ enum_column_usage item_list_usage;
bool is_item_list_lookup:1;
/*
Needed to correctly generate 'PRIMARY' or 'SIMPLE' for select_type column
@@ -1646,6 +1652,7 @@ public:
void lex_start(LEX *plex);
bool is_unit_nest() { return (nest_flags & UNIT_NEST_FL); }
void mark_as_unit_nest() { nest_flags= UNIT_NEST_FL; }
+ bool is_sj_conversion_prohibited(THD *thd);
};
typedef class st_select_lex SELECT_LEX;
@@ -1754,12 +1761,31 @@ public:
Sroutine_hash_entry **sroutines_list_own_last;
uint sroutines_list_own_elements;
+ /**
+ Locking state of tables in this particular statement.
+
+ If we under LOCK TABLES or in prelocked mode we consider tables
+ for the statement to be "locked" if there was a call to lock_tables()
+ (which called handler::start_stmt()) for tables of this statement
+ and there was no matching close_thread_tables() call.
+
+ As result this state may differ significantly from one represented
+ by Open_tables_state::lock/locked_tables_mode more, which are always
+ "on" under LOCK TABLES or in prelocked mode.
+ */
+ enum enum_lock_tables_state { LTS_NOT_LOCKED = 0, LTS_LOCKED };
+ enum_lock_tables_state lock_tables_state;
+ bool is_query_tables_locked() const
+ {
+ return (lock_tables_state == LTS_LOCKED);
+ }
+
/*
These constructor and destructor serve for creation/destruction
of Query_tables_list instances which are used as backup storage.
*/
- Query_tables_list() = default;
- ~Query_tables_list() = default;
+ Query_tables_list() : lock_tables_state(LTS_NOT_LOCKED) {}
+ ~Query_tables_list() {}
/* Initializes (or resets) Query_tables_list object for "real" use. */
void reset_query_tables_list(bool init);
@@ -3388,6 +3414,7 @@ public:
bool default_used:1; /* using default() function */
bool with_rownum:1; /* Using rownum() function */
bool is_lex_started:1; /* If lex_start() did run. For debugging. */
+
/*
This variable is used in post-parse stage to declare that sum-functions,
or functions which have sense only if GROUP BY is present, are allowed.
diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc
index dd19807dd6d..eb5e3fbbc5a 100644
--- a/sql/sql_locale.cc
+++ b/sql/sql_locale.cc
@@ -31,7 +31,7 @@ enum err_msgs_index
{
en_US= 0, cs_CZ, da_DK, nl_NL, et_EE, fr_FR, de_DE, el_GR, hu_HU, it_IT,
ja_JP, ko_KR, no_NO, nn_NO, pl_PL, pt_PT, ro_RO, ru_RU, sr_RS, sk_SK,
- es_ES, sv_SE, uk_UA, hi_IN
+ es_ES, sv_SE, uk_UA, hi_IN, ka_GE
} ERR_MSGS_INDEX;
@@ -61,6 +61,7 @@ MY_LOCALE_ERRMSGS global_errmsgs[]=
{"swedish", NULL},
{"ukrainian", NULL},
{"hindi", NULL},
+ {"georgian", NULL},
{NULL, NULL}
};
@@ -3317,6 +3318,51 @@ MY_LOCALE my_locale_rm_CH
/***** LOCALE END rm_CH *****/
+/***** LOCALE BEGIN ka_GE: Georgian - Georgia *****/
+static const char *my_locale_month_names_ka_GE[13] =
+ {"იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი", NullS };
+
+static const char *my_locale_ab_month_names_ka_GE[13] =
+ {"იან","თებ","მარ","აპრ","მაი","ივნ","ივლ","აგვ","სექტ","ოქტ","ნოე","დეკ", NullS };
+
+static const char *my_locale_day_names_ka_GE[8] =
+ {"ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი","კვირა", NullS };
+
+static const char *my_locale_ab_day_names_ka_GE[8] =
+ {"ორშ","სამშ","ოთხშ","ხუთშ","პარ","შაბ","კვ", NullS };
+
+static TYPELIB my_locale_typelib_month_names_ka_GE =
+ { array_elements(my_locale_month_names_ka_GE)-1, "", my_locale_month_names_ka_GE, NULL };
+
+static TYPELIB my_locale_typelib_ab_month_names_ka_GE =
+ { array_elements(my_locale_ab_month_names_ka_GE)-1, "", my_locale_ab_month_names_ka_GE, NULL };
+
+static TYPELIB my_locale_typelib_day_names_ka_GE =
+ { array_elements(my_locale_day_names_ka_GE)-1, "", my_locale_day_names_ka_GE, NULL };
+
+static TYPELIB my_locale_typelib_ab_day_names_ka_GE =
+ { array_elements(my_locale_ab_day_names_ka_GE)-1, "", my_locale_ab_day_names_ka_GE, NULL };
+
+MY_LOCALE my_locale_ka_GE
+(
+ 111,
+ "ka_GE",
+ "Georgian - Georgia",
+ FALSE,
+ &my_locale_typelib_month_names_ka_GE,
+ &my_locale_typelib_ab_month_names_ka_GE,
+ &my_locale_typelib_day_names_ka_GE,
+ &my_locale_typelib_ab_day_names_ka_GE,
+ 10,
+ 9,
+ ',', /* decimal point ka_GE */
+ ' ', /* thousands_sep ka_GE */
+ "\x03", /* grouping ka_GE */
+ &global_errmsgs[ka_GE]
+);
+/***** LOCALE END ka_GE *****/
+
+
/*
The list of all locales.
Note, locales must be ordered according to their
@@ -3436,6 +3482,7 @@ MY_LOCALE *my_locales[]=
&my_locale_zh_HK,
&my_locale_el_GR,
&my_locale_rm_CH,
+ &my_locale_ka_GE,
NULL
};
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7a171174a72..67353a1f082 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -34,9 +34,7 @@
#include "sql_locale.h" // my_locale_en_US
#include "log.h" // flush_error_log
#include "sql_view.h" // mysql_create_view, mysql_drop_view
-#include "sql_delete.h" // mysql_delete
#include "sql_insert.h" // mysql_insert
-#include "sql_update.h" // mysql_update, mysql_multi_update
#include "sql_partition.h" // struct partition_info
#include "sql_db.h" // mysql_change_db, mysql_create_db,
// mysql_rm_db, mysql_upgrade_db,
@@ -3445,7 +3443,6 @@ int
mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
{
int res= 0;
- int up_result= 0;
LEX *lex= thd->lex;
/* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */
SELECT_LEX *select_lex= lex->first_select_lex();
@@ -3457,7 +3454,6 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
SELECT_LEX_UNIT *unit= &lex->unit;
#ifdef HAVE_REPLICATION
/* have table map for update for multi-update statement (BUG#37051) */
- bool have_table_map_for_update= FALSE;
/* */
Rpl_filter *rpl_filter;
#endif
@@ -3579,7 +3575,6 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
if (lex->sql_command == SQLCOM_UPDATE_MULTI &&
thd->table_map_for_update)
{
- have_table_map_for_update= TRUE;
table_map table_map_for_update= thd->table_map_for_update;
uint nr= 0;
TABLE_LIST *table;
@@ -4388,130 +4383,15 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
break;
}
case SQLCOM_UPDATE:
- {
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
- ha_rows found= 0, updated= 0;
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
-
- if (update_precheck(thd, all_tables))
- break;
-
- /*
- UPDATE IGNORE can be unsafe. We therefore use row based
- logging if mixed or row based logging is available.
- TODO: Check if the order of the output of the select statement is
- deterministic. Waiting for BUG#42415
- */
- if (lex->ignore)
- lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UPDATE_IGNORE);
-
- DBUG_ASSERT(select_lex->limit_params.offset_limit == 0);
- unit->set_limit(select_lex);
- MYSQL_UPDATE_START(thd->query());
- res= up_result= mysql_update(thd, all_tables,
- select_lex->item_list,
- lex->value_list,
- select_lex->where,
- select_lex->order_list.elements,
- select_lex->order_list.first,
- unit->lim.get_select_limit(),
- lex->ignore, &found, &updated);
- MYSQL_UPDATE_DONE(res, found, updated);
- /* mysql_update return 2 if we need to switch to multi-update */
- if (up_result != 2)
- break;
- if (thd->lex->period_conditions.is_set())
- {
- DBUG_ASSERT(0); // Should never happen
- goto error;
- }
- }
- /* fall through */
case SQLCOM_UPDATE_MULTI:
+ case SQLCOM_DELETE:
+ case SQLCOM_DELETE_MULTI:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
- /* if we switched from normal update, rights are checked */
- if (up_result != 2)
- {
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
- if ((res= multi_update_precheck(thd, all_tables)))
- break;
- }
- else
- res= 0;
-
- unit->set_limit(select_lex);
- /*
- We can not use mysql_explain_union() because of parameters of
- mysql_select in mysql_multi_update so just set the option if needed
- */
- if (thd->lex->describe)
- {
- select_lex->set_explain_type(FALSE);
- select_lex->options|= SELECT_DESCRIBE;
- }
-
- res= mysql_multi_update_prepare(thd);
+ DBUG_ASSERT(lex->m_sql_cmd != NULL);
-#ifdef HAVE_REPLICATION
- /* Check slave filtering rules */
- if (unlikely(thd->slave_thread && !have_table_map_for_update))
- {
- if (all_tables_not_ok(thd, all_tables))
- {
- if (res!= 0)
- {
- res= 0; /* don't care of prev failure */
- thd->clear_error(); /* filters are of highest prior */
- }
- /* we warn the slave SQL thread */
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
- break;
- }
- if (res)
- break;
- }
- else
- {
-#endif /* HAVE_REPLICATION */
- if (res)
- break;
- if (opt_readonly &&
- !(thd->security_ctx->master_access & PRIV_IGNORE_READ_ONLY) &&
- some_non_temp_table_to_be_updated(thd, all_tables))
- {
- my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
- break;
- }
-#ifdef HAVE_REPLICATION
- } /* unlikely */
-#endif
- {
- multi_update *result_obj;
- MYSQL_MULTI_UPDATE_START(thd->query());
- res= mysql_multi_update(thd, all_tables,
- &select_lex->item_list,
- &lex->value_list,
- select_lex->where,
- select_lex->options,
- lex->duplicates,
- lex->ignore,
- unit,
- select_lex,
- &result_obj);
- if (result_obj)
- {
- MYSQL_MULTI_UPDATE_DONE(res, result_obj->num_found(),
- result_obj->num_updated());
- res= FALSE; /* Ignore errors here */
- delete result_obj;
- }
- else
- {
- MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
- }
- }
+ res = lex->m_sql_cmd->execute(thd);
+ thd->abort_on_warning= 0;
break;
}
case SQLCOM_REPLACE:
@@ -4773,129 +4653,6 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
break;
}
- case SQLCOM_DELETE:
- {
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
- select_result *sel_result= NULL;
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
-
- if ((res= delete_precheck(thd, all_tables)))
- break;
- DBUG_ASSERT(select_lex->limit_params.offset_limit == 0);
- unit->set_limit(select_lex);
-
- MYSQL_DELETE_START(thd->query());
- Protocol *save_protocol= NULL;
-
- if (lex->has_returning())
- {
- /* This is DELETE ... RETURNING. It will return output to the client */
- if (thd->lex->analyze_stmt)
- {
- /*
- Actually, it is ANALYZE .. DELETE .. RETURNING. We need to produce
- output and then discard it.
- */
- sel_result= new (thd->mem_root) select_send_analyze(thd);
- save_protocol= thd->protocol;
- thd->protocol= new Protocol_discard(thd);
- }
- else
- {
- if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd)))
- goto error;
- }
- }
-
- res = mysql_delete(thd, all_tables,
- select_lex->where, &select_lex->order_list,
- unit->lim.get_select_limit(), select_lex->options,
- lex->result ? lex->result : sel_result);
-
- if (save_protocol)
- {
- delete thd->protocol;
- thd->protocol= save_protocol;
- }
-
- if (thd->lex->analyze_stmt || thd->lex->describe)
- {
- if (!res)
- res= thd->lex->explain->send_explain(thd);
- }
-
- delete sel_result;
- MYSQL_DELETE_DONE(res, (ulong) thd->get_row_count_func());
- break;
- }
- case SQLCOM_DELETE_MULTI:
- {
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first;
- multi_delete *result;
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
-
- if ((res= multi_delete_precheck(thd, all_tables)))
- break;
-
- /* condition will be TRUE on SP re-excuting */
- if (select_lex->item_list.elements != 0)
- select_lex->item_list.empty();
- if (add_item_to_list(thd, new (thd->mem_root) Item_null(thd)))
- goto error;
-
- THD_STAGE_INFO(thd, stage_init);
- if ((res= open_and_lock_tables(thd, all_tables, TRUE, 0)))
- break;
-
- MYSQL_MULTI_DELETE_START(thd->query());
- if (unlikely(res= mysql_multi_delete_prepare(thd)))
- {
- MYSQL_MULTI_DELETE_DONE(1, 0);
- goto error;
- }
-
- if (likely(!thd->is_fatal_error))
- {
- result= new (thd->mem_root) multi_delete(thd, aux_tables,
- lex->table_count_update);
- if (likely(result))
- {
- if (unlikely(select_lex->vers_setup_conds(thd, aux_tables)))
- goto multi_delete_error;
- res= mysql_select(thd,
- select_lex->get_table_list(),
- select_lex->item_list,
- select_lex->where,
- 0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL,
- (ORDER *)NULL,
- (select_lex->options | thd->variables.option_bits |
- SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
- OPTION_SETUP_TABLES_DONE) & ~OPTION_BUFFER_RESULT,
- result, unit, select_lex);
- res|= (int)(thd->is_error());
-
- MYSQL_MULTI_DELETE_DONE(res, result->num_deleted());
- if (res)
- result->abort_result_set(); /* for both DELETE and EXPLAIN DELETE */
- else
- {
- if (lex->describe || lex->analyze_stmt)
- res= thd->lex->explain->send_explain(thd);
- }
- multi_delete_error:
- delete result;
- }
- }
- else
- {
- res= TRUE; // Error
- MYSQL_MULTI_DELETE_DONE(1, 0);
- }
- break;
- }
case SQLCOM_DROP_SEQUENCE:
case SQLCOM_DROP_TABLE:
{
@@ -7733,12 +7490,16 @@ void create_select_for_variable(THD *thd, LEX_CSTRING *var_name)
}
-void mysql_init_multi_delete(LEX *lex)
+void mysql_init_delete(LEX *lex)
{
- lex->sql_command= SQLCOM_DELETE_MULTI;
lex->init_select();
lex->first_select_lex()->limit_params.clear();
lex->unit.lim.clear();
+}
+
+void mysql_init_multi_delete(LEX *lex)
+{
+ lex->sql_command= SQLCOM_DELETE_MULTI;
lex->first_select_lex()->table_list.
save_and_clear(&lex->auxiliary_table_list);
lex->query_tables= 0;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index eeb7f832adb..f6c2c086ae6 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -92,6 +92,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
bool mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *sel);
void create_select_for_variable(THD *thd, LEX_CSTRING *var_name);
void create_table_set_open_action_and_adjust_tables(LEX *lex);
+void mysql_init_delete(LEX *lex);
void mysql_init_multi_delete(LEX *lex);
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
void create_table_set_open_action_and_adjust_tables(LEX *lex);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 1e84471eef2..22780c894f8 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -95,10 +95,8 @@ When one supplies long data for a placeholder:
#include "sql_base.h" // open_normal_and_derived_tables
#include "sql_cache.h" // query_cache_*
#include "sql_view.h" // create_view_precheck
-#include "sql_delete.h" // mysql_prepare_delete
#include "sql_select.h" // for JOIN
#include "sql_insert.h" // upgrade_lock_type_for_insert, mysql_prepare_insert
-#include "sql_update.h" // mysql_prepare_update
#include "sql_db.h" // mysql_opt_change_db, mysql_change_db
#include "sql_derived.h" // mysql_derived_prepare,
// mysql_handle_derived
@@ -1402,162 +1400,6 @@ static bool mysql_test_insert(Prepared_statement *stmt,
/**
- Validate UPDATE statement.
-
- @param stmt prepared statement
- @param tables list of tables used in this query
-
- @todo
- - here we should send types of placeholders to the client.
-
- @retval
- 0 success
- @retval
- 1 error, error message is set in THD
- @retval
- 2 convert to multi_update
-*/
-
-static int mysql_test_update(Prepared_statement *stmt,
- TABLE_LIST *table_list)
-{
- int res;
- THD *thd= stmt->thd;
- uint table_count= 0;
- TABLE_LIST *update_source_table;
- SELECT_LEX *select= stmt->lex->first_select_lex();
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- privilege_t want_privilege(NO_ACL);
-#endif
- DBUG_ENTER("mysql_test_update");
-
- if (update_precheck(thd, table_list) ||
- open_tables(thd, &table_list, &table_count, MYSQL_OPEN_FORCE_SHARED_MDL))
- goto error;
-
- if (mysql_handle_derived(thd->lex, DT_INIT))
- goto error;
-
- if (((update_source_table= unique_table(thd, table_list,
- table_list->next_global, 0)) ||
- table_list->is_multitable()))
- {
- DBUG_ASSERT(update_source_table || table_list->view != 0);
- DBUG_PRINT("info", ("Switch to multi-update"));
- /* pass counter value */
- thd->lex->table_count_update= table_count;
- /* convert to multiupdate */
- DBUG_RETURN(2);
- }
-
- /*
- thd->fill_derived_tables() is false here for sure (because it is
- preparation of PS, so we even do not check it).
- */
- if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
- goto error;
- if (table_list->handle_derived(thd->lex, DT_PREPARE))
- goto error;
-
- if (!table_list->single_table_updatable())
- {
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE");
- goto error;
- }
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* Force privilege re-checking for views after they have been opened. */
- want_privilege= (table_list->view ? UPDATE_ACL :
- table_list->grant.want_privilege);
-#endif
-
- if (mysql_prepare_update(thd, table_list, &select->where,
- select->order_list.elements,
- select->order_list.first))
- goto error;
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= want_privilege;
- table_list->table->grant.want_privilege= want_privilege;
- table_list->register_want_access(want_privilege);
-#endif
- thd->lex->first_select_lex()->no_wrap_view_item= TRUE;
- res= setup_fields(thd, Ref_ptr_array(),
- select->item_list, MARK_COLUMNS_READ, 0, NULL, 0);
- thd->lex->first_select_lex()->no_wrap_view_item= FALSE;
- if (res)
- goto error;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* Check values */
- table_list->grant.want_privilege=
- table_list->table->grant.want_privilege=
- (SELECT_ACL & ~table_list->table->grant.privilege);
- table_list->register_want_access(SELECT_ACL);
-#endif
- if (setup_fields(thd, Ref_ptr_array(),
- stmt->lex->value_list, COLUMNS_READ, 0, NULL, 0) ||
- check_unique_table(thd, table_list))
- goto error;
- /* TODO: here we should send types of placeholders to the client. */
- DBUG_RETURN(0);
-error:
- DBUG_RETURN(1);
-}
-
-
-/**
- Validate DELETE statement.
-
- @param stmt prepared statement
- @param tables list of tables used in this query
-
- @retval
- FALSE success
- @retval
- TRUE error, error message is set in THD
-*/
-
-static bool mysql_test_delete(Prepared_statement *stmt,
- TABLE_LIST *table_list)
-{
- uint table_count= 0;
- THD *thd= stmt->thd;
- LEX *lex= stmt->lex;
- bool delete_while_scanning;
- DBUG_ENTER("mysql_test_delete");
-
- if (delete_precheck(thd, table_list) ||
- open_tables(thd, &table_list, &table_count, MYSQL_OPEN_FORCE_SHARED_MDL))
- goto error;
-
- if (mysql_handle_derived(thd->lex, DT_INIT))
- goto error;
- if (mysql_handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
- goto error;
- if (mysql_handle_derived(thd->lex, DT_PREPARE))
- goto error;
-
- if (!table_list->single_table_updatable())
- {
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
- goto error;
- }
- if (!table_list->table || !table_list->table->is_created())
- {
- my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
- table_list->view_db.str, table_list->view_name.str);
- goto error;
- }
-
- DBUG_RETURN(mysql_prepare_delete(thd, table_list,
- &lex->first_select_lex()->where,
- &delete_while_scanning));
-error:
- DBUG_RETURN(TRUE);
-}
-
-
-/**
Validate SELECT statement.
In case of success, if this query is not EXPLAIN, send column list info
@@ -2137,74 +1979,6 @@ err:
}
-/*
- Validate and prepare for execution a multi update statement.
-
- @param stmt prepared statement
- @param tables list of tables used in this query
- @param converted converted to multi-update from usual update
-
- @retval
- FALSE success
- @retval
- TRUE error, error message is set in THD
-*/
-
-static bool mysql_test_multiupdate(Prepared_statement *stmt,
- TABLE_LIST *tables,
- bool converted)
-{
- /* if we switched from normal update, rights are checked */
- if (!converted && multi_update_precheck(stmt->thd, tables))
- return TRUE;
-
- return select_like_stmt_test(stmt, &mysql_multi_update_prepare,
- OPTION_SETUP_TABLES_DONE);
-}
-
-
-/**
- Validate and prepare for execution a multi delete statement.
-
- @param stmt prepared statement
- @param tables list of tables used in this query
-
- @retval
- FALSE success
- @retval
- TRUE error, error message in THD is set.
-*/
-
-static bool mysql_test_multidelete(Prepared_statement *stmt,
- TABLE_LIST *tables)
-{
- THD *thd= stmt->thd;
-
- thd->lex->current_select= thd->lex->first_select_lex();
- if (add_item_to_list(thd, new (thd->mem_root)
- Item_null(thd)))
- {
- my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), 0);
- goto error;
- }
-
- if (multi_delete_precheck(thd, tables) ||
- select_like_stmt_test_with_open(stmt, tables,
- &mysql_multi_delete_prepare,
- OPTION_SETUP_TABLES_DONE))
- goto error;
- if (!tables->table)
- {
- my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
- tables->view_db.str, tables->view_name.str);
- goto error;
- }
- return FALSE;
-error:
- return TRUE;
-}
-
-
/**
Wrapper for mysql_insert_select_prepare, to make change of local tables
after open_normal_and_derived_tables() call.
@@ -2486,18 +2260,14 @@ static bool check_prepared_statement(Prepared_statement *stmt)
break;
case SQLCOM_UPDATE:
- res= mysql_test_update(stmt, tables);
- /* mysql_test_update returns 2 if we need to switch to multi-update */
- if (res != 2)
- break;
- /* fall through */
case SQLCOM_UPDATE_MULTI:
- res= mysql_test_multiupdate(stmt, tables, res == 2);
- break;
-
case SQLCOM_DELETE:
- res= mysql_test_delete(stmt, tables);
+ case SQLCOM_DELETE_MULTI:
+ res = lex->m_sql_cmd->prepare(thd);
+ if (!res)
+ lex->m_sql_cmd->unprepare(thd);
break;
+
/* The following allow WHERE clause, so they must be tested like SELECT */
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_TABLES:
@@ -2634,10 +2404,6 @@ static bool check_prepared_statement(Prepared_statement *stmt)
res= mysql_test_set_fields(stmt, tables, &lex->var_list);
break;
- case SQLCOM_DELETE_MULTI:
- res= mysql_test_multidelete(stmt, tables);
- break;
-
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE_SELECT:
res= mysql_test_insert_select(stmt, tables);
@@ -4373,6 +4139,9 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
thd->is_error() ||
init_param_array(this));
+ if (lex->m_sql_cmd)
+ lex->m_sql_cmd->set_owner(this);
+
if (thd->security_ctx->password_expired &&
lex->sql_command != SQLCOM_SET_OPTION &&
lex->sql_command != SQLCOM_PREPARE &&
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 26987c9072e..4b01a96a132 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1486,7 +1486,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
}
}
- if (setup_fields(thd, ref_ptrs, fields_list, MARK_COLUMNS_READ,
+ if (setup_fields(thd, ref_ptrs, fields_list, select_lex->item_list_usage,
&all_fields, &select_lex->pre_fix, 1))
DBUG_RETURN(-1);
thd->lex->current_select->context_analysis_place= save_place;
@@ -1775,6 +1775,8 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
if (!procedure && result && result->prepare(fields_list, unit_arg))
goto err; /* purecov: inspected */
+ select_lex->where_cond_after_prepare= conds;
+
unit= unit_arg;
if (prepare_stage2())
goto err;
@@ -5970,8 +5972,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->needed_reg=select->needed_reg;
select->quick=0;
impossible_range= records == 0 && s->table->reginfo.impossible_range;
- if (join->thd->lex->sql_command == SQLCOM_SELECT &&
- optimizer_flag(join->thd, OPTIMIZER_SWITCH_USE_ROWID_FILTER))
+ if (optimizer_flag(join->thd, OPTIMIZER_SWITCH_USE_ROWID_FILTER))
s->table->init_cost_info_for_usable_range_rowid_filters(join->thd);
}
if (!impossible_range)
@@ -30846,7 +30847,8 @@ static bool get_range_limit_read_cost(const POSITION *pos,
@note
This function takes into account table->opt_range_condition_rows statistic
(that is calculated by the make_join_statistics function).
- However, single table procedures such as mysql_update() and mysql_delete()
+ However, single table procedures such as Sql_cmd_update:update_single_table()
+ and Sql_cmd_delete::delete_single_table()
never call make_join_statistics, so they have to update it manually
(@see get_index_for_order()).
*/
@@ -32341,6 +32343,273 @@ bool JOIN::transform_all_conds_and_on_exprs_in_join_list(
return false;
}
+
+static void MYSQL_DML_START(THD *thd)
+{
+ switch (thd->lex->sql_command) {
+
+ case SQLCOM_UPDATE:
+ MYSQL_UPDATE_START(thd->query());
+ break;
+ case SQLCOM_UPDATE_MULTI:
+ MYSQL_MULTI_UPDATE_START(thd->query());
+ break;
+ case SQLCOM_DELETE:
+ MYSQL_DELETE_START(thd->query());
+ break;
+ case SQLCOM_DELETE_MULTI:
+ MYSQL_MULTI_DELETE_START(thd->query());
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+}
+
+
+static void MYSQL_DML_DONE(THD *thd, int rc)
+{
+ switch (thd->lex->sql_command) {
+
+ case SQLCOM_UPDATE:
+ MYSQL_UPDATE_DONE(
+ rc,
+ (rc ? 0 :
+ ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
+ ->num_found()),
+ (rc ? 0 :
+ ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
+ ->num_updated()));
+ break;
+ case SQLCOM_UPDATE_MULTI:
+ MYSQL_MULTI_UPDATE_DONE(
+ rc,
+ (rc ? 0 :
+ ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
+ ->num_found()),
+ (rc ? 0 :
+ ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
+ ->num_updated()));
+ break;
+ case SQLCOM_DELETE:
+ MYSQL_DELETE_DONE(rc, (rc ? 0 : (ulong) (thd->get_row_count_func())));
+ break;
+ case SQLCOM_DELETE_MULTI:
+ MYSQL_MULTI_DELETE_DONE(
+ rc,
+ (rc ? 0 :
+ ((multi_delete*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
+ ->num_deleted()));
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+}
+
+
+/*
+ @brief Perform actions needed before locking tables for a DML statement
+
+ @param thd global context the processed statement
+ @returns false if success, true if error
+
+ @details
+ This function calls the precheck() procedure fo the processed statement,
+ then is opens tables used in the statement and finally it calls the function
+ prepare_inner() that is specific for the type of the statement.
+
+ @note
+ The function are used when processing:
+ - a DML statement
+ - PREPARE stmt FROM <DML "statement>"
+ - EXECUTE stmt when stmt is prepared from a DML statement.
+*/
+
+bool Sql_cmd_dml::prepare(THD *thd)
+{
+ lex= thd->lex;
+ SELECT_LEX_UNIT *unit= &lex->unit;
+
+ DBUG_ASSERT(!is_prepared());
+
+ // Perform a coarse statement-specific privilege check.
+ if (precheck(thd))
+ goto err;
+
+ MYSQL_DML_START(thd);
+
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
+
+ if (open_tables_for_query(thd, lex->query_tables, &table_count, 0,
+ get_dml_prelocking_strategy()))
+ {
+ if (thd->is_error())
+ goto err;
+ (void)unit->cleanup();
+ return true;
+ }
+
+ if (prepare_inner(thd))
+ goto err;
+
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
+
+ set_prepared();
+ unit->set_prepared();
+
+ return false;
+
+err:
+ DBUG_ASSERT(thd->is_error());
+ DBUG_PRINT("info", ("report_error: %d", thd->is_error()));
+
+ (void)unit->cleanup();
+
+ return true;
+}
+
+
+/**
+ @brief Execute a DML statement
+
+ @param thd global context the processed statement
+ @returns false if success, true if error
+
+ @details
+ The function assumes that each type of a DML statement has its own
+ implementation of the virtunal functions precheck(). It is also
+ assumed that that the virtual function execute execute_inner() is to be
+ overridden by the implementations for specific commands.
+
+ @note
+ Currently only UPDATE and DELETE statement are executed using this function.
+*/
+
+bool Sql_cmd_dml::execute(THD *thd)
+{
+ lex = thd->lex;
+ bool res;
+
+ SELECT_LEX_UNIT *unit = &lex->unit;
+ SELECT_LEX *select_lex= lex->first_select_lex();
+
+ if (!is_prepared())
+ {
+ /*
+ This is called when processing
+ - a DML statement
+ - PREPARE stmt FROM <DML "statement>"
+ - EXECUTE stmt when stmt is prepared from a DML statement.
+ The call will invoke open_tables_for_query()
+ */
+ if (prepare(thd))
+ goto err;
+ }
+ else // This branch currently is never used for DML commands
+ {
+ if (precheck(thd))
+ goto err;
+
+ MYSQL_DML_START(thd);
+
+ if (open_tables_for_query(thd, lex->query_tables, &table_count, 0,
+ get_dml_prelocking_strategy()))
+ goto err;
+ }
+
+ THD_STAGE_INFO(thd, stage_init);
+
+ /*
+ Locking of tables is done after preparation but before optimization.
+ This allows to do better partition pruning and avoid locking unused
+ partitions. As a consequence, in such a case, prepare stage can rely only
+ on metadata about tables used and not data from them.
+ */
+ if (!is_empty_query())
+ {
+ if (lock_tables(thd, lex->query_tables, table_count, 0))
+ goto err;
+ }
+
+ unit->set_limit(select_lex);
+
+ /* Perform statement-specific execution */
+ res = execute_inner(thd);
+
+ if (res)
+ goto err;
+
+ res= unit->cleanup();
+
+ /* "Unprepare" this object since unit->cleanup actually unprepares */
+ unprepare(thd);
+
+ THD_STAGE_INFO(thd, stage_end);
+
+ MYSQL_DML_DONE(thd, res);
+
+ return res;
+
+err:
+ DBUG_ASSERT(thd->is_error() || thd->killed);
+ MYSQL_DML_DONE(thd, 1);
+ THD_STAGE_INFO(thd, stage_end);
+ (void)unit->cleanup();
+ if (is_prepared())
+ unprepare(thd);
+
+ return thd->is_error();
+}
+
+
+/**
+ @brief Generic implemention of optimization and execution phases
+ @param thd global context the processed statement
+ @returns false if success, true if error
+
+ @note
+ This implementation assumes that the processed DML statement is represented
+ as a SELECT_LEX or SELECT_LEX_UNIT tree with attached corresponding
+ JOIN structures. Any JOIN structure is constructed at the prepare phase.
+ When created at the top level join it is provided with an object of a class
+ derived from select_result_sink. The pointer to the object is saved in
+ the this->result field. For different types of DML statements different
+ derived classes are used for this object. The class of this object determines
+ additional specific actions performed at the phases of context analysis,
+ optimization and execution.
+*/
+
+bool Sql_cmd_dml::execute_inner(THD *thd)
+{
+ SELECT_LEX_UNIT *unit = &lex->unit;
+ SELECT_LEX *select_lex= unit->first_select();
+ JOIN *join= select_lex->join;
+
+ if (join->optimize())
+ goto err;
+
+ if (thd->lex->describe & DESCRIBE_EXTENDED)
+ {
+ join->conds_history= join->conds;
+ join->having_history= (join->having?join->having:join->tmp_having);
+ }
+
+ if (unlikely(thd->is_error()))
+ goto err;
+
+ if (join->exec())
+ goto err;
+
+ if (thd->lex->describe & DESCRIBE_EXTENDED)
+ {
+ select_lex->where= join->conds_history;
+ select_lex->having= join->having_history;
+ }
+
+err:
+ return join->error;
+}
+
+
/**
@} (end of group Query_Optimizer)
*/
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 94371b53303..26a58e66ffe 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2396,17 +2396,16 @@ static void check_duplicate_key(THD *thd, const Key *key, const KEY *key_info,
bool Column_definition::prepare_stage1_typelib(THD *thd,
MEM_ROOT *mem_root,
- handler *file,
- ulonglong table_flags)
+ column_definition_type_t deftype)
{
/*
Pass the last parameter to prepare_interval_field() as follows:
- - If we are preparing for an SP variable (file is NULL), we pass "false",
+ - If we are preparing for an SP variable, we pass "false",
to force allocation and full copying of TYPELIB values on the given
mem_root, even if no character set conversion is needed. This is needed
because a life cycle of an SP variable is longer than the current query.
- - If we are preparing for a CREATE TABLE, (file != NULL), we pass "true".
+ - If we are preparing for a CREATE TABLE, we pass "true".
This will create the typelib in runtime memory - we will free the
occupied memory at the same time when we free this
sql_field -- at the end of execution.
@@ -2414,11 +2413,11 @@ bool Column_definition::prepare_stage1_typelib(THD *thd,
values in "interval" in cases when no character conversion is needed,
to avoid extra copying.
*/
- if (prepare_interval_field(mem_root, file != NULL))
+ if (prepare_interval_field(mem_root,
+ deftype == COLUMN_DEFINITION_TABLE_FIELD))
return true; // E.g. wrong values with commas: SET('a,b')
create_length_to_internal_length_typelib();
- DBUG_ASSERT(file || !default_value); // SP variables have no default_value
if (default_value && default_value->expr->basic_const_item())
{
if ((charset != default_value->expr->collation.collation &&
@@ -2431,14 +2430,11 @@ bool Column_definition::prepare_stage1_typelib(THD *thd,
bool Column_definition::prepare_stage1_string(THD *thd,
- MEM_ROOT *mem_root,
- handler *file,
- ulonglong table_flags)
+ MEM_ROOT *mem_root)
{
create_length_to_internal_length_string();
if (prepare_blob_field(thd))
return true;
- DBUG_ASSERT(file || !default_value); // SP variables have no default_value
/*
Convert the default value from client character
set into the column character set if necessary.
@@ -2458,13 +2454,9 @@ bool Column_definition::prepare_stage1_string(THD *thd,
bool Column_definition::prepare_stage1_bit(THD *thd,
- MEM_ROOT *mem_root,
- handler *file,
- ulonglong table_flags)
+ MEM_ROOT *mem_root)
{
pack_flag= FIELDFLAG_NUMBER;
- if (!(table_flags & HA_CAN_BIT_FIELD))
- pack_flag|= FIELDFLAG_TREAT_BIT_AS_CHAR;
create_length_to_internal_length_bit();
return false;
}
@@ -2472,14 +2464,15 @@ bool Column_definition::prepare_stage1_bit(THD *thd,
bool Column_definition::prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t deftype,
const Column_derived_attributes
*derived_attr)
{
+ // SP variables have no default_value
+ DBUG_ASSERT(deftype == COLUMN_DEFINITION_TABLE_FIELD || !default_value);
+
return type_handler()->Column_definition_prepare_stage1(thd, mem_root,
- this, file,
- table_flags,
+ this, deftype,
derived_attr);
}
@@ -2703,10 +2696,77 @@ key_add_part_check_null(const handler *file, KEY *key_info,
/*
- Preparation for table creation
+ Prepare for a table creation.
+ Stage 1: prepare the field list.
+*/
+static bool mysql_prepare_create_table_stage1(THD *thd,
+ HA_CREATE_INFO *create_info,
+ Alter_info *alter_info)
+{
+ DBUG_ENTER("mysql_prepare_create_table_stage1");
+ const Column_derived_attributes dattr(create_info->default_table_charset);
+ const Column_bulk_alter_attributes
+ battr(create_info->alter_table_convert_to_charset);
+ Create_field *sql_field;
+ List_iterator_fast<Create_field> it(alter_info->create_list);
+
+ DBUG_EXECUTE_IF("test_pseudo_invisible",{
+ mysql_add_invisible_field(thd, &alter_info->create_list,
+ "invisible", &type_handler_slong, INVISIBLE_SYSTEM,
+ new (thd->mem_root)Item_int(thd, 9));
+ });
+ DBUG_EXECUTE_IF("test_completely_invisible",{
+ mysql_add_invisible_field(thd, &alter_info->create_list,
+ "invisible", &type_handler_slong, INVISIBLE_FULL,
+ new (thd->mem_root)Item_int(thd, 9));
+ });
+ DBUG_EXECUTE_IF("test_invisible_index",{
+ LEX_CSTRING temp;
+ temp.str= "invisible";
+ temp.length= strlen("invisible");
+ mysql_add_invisible_index(thd, &alter_info->key_list
+ , &temp, Key::MULTIPLE);
+ });
+
+
+ for ( ; (sql_field=it++) ; )
+ {
+ /* Virtual fields are always NULL */
+ if (sql_field->vcol_info)
+ sql_field->flags&= ~NOT_NULL_FLAG;
+
+ /*
+ Initialize length from its original value (number of characters),
+ which was set in the parser. This is necessary if we're
+ executing a prepared statement for the second time.
+ */
+ sql_field->length= sql_field->char_length;
+
+ if (sql_field->bulk_alter(&dattr, &battr))
+ DBUG_RETURN(true);
+
+ if (sql_field->prepare_stage1(thd, thd->mem_root,
+ COLUMN_DEFINITION_TABLE_FIELD,
+ &dattr))
+ DBUG_RETURN(true);
+
+ DBUG_ASSERT(sql_field->charset);
+
+ if (check_column_name(sql_field->field_name.str))
+ {
+ my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name.str);
+ DBUG_RETURN(TRUE);
+ }
+ }
+ DBUG_RETURN(false);
+}
+
+
+/*
+ Preparation for table creation, final stage.
SYNOPSIS
- mysql_prepare_create_table()
+ mysql_prepare_create_table_finalize()
thd Thread object.
create_info Create information (like MAX_ROWS).
alter_info List of columns and indexes to create
@@ -2729,11 +2789,12 @@ key_add_part_check_null(const handler *file, KEY *key_info,
*/
static int
-mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
- Alter_info *alter_info, uint *db_options,
- handler *file, KEY **key_info_buffer,
- uint *key_count, int create_table_mode,
- const LEX_CSTRING db, const LEX_CSTRING table_name)
+mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
+ Alter_info *alter_info, uint *db_options,
+ handler *file, KEY **key_info_buffer,
+ uint *key_count, int create_table_mode,
+ const LEX_CSTRING db,
+ const LEX_CSTRING table_name)
{
const char *key_name;
Create_field *sql_field,*dup_field;
@@ -2749,28 +2810,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
bool tmp_table= create_table_mode == C_ALTER_TABLE;
const bool create_simple= thd->lex->create_simple();
bool is_hash_field_needed= false;
- const Column_derived_attributes dattr(create_info->default_table_charset);
- const Column_bulk_alter_attributes
- battr(create_info->alter_table_convert_to_charset);
DBUG_ENTER("mysql_prepare_create_table");
- DBUG_EXECUTE_IF("test_pseudo_invisible",{
- mysql_add_invisible_field(thd, &alter_info->create_list,
- "invisible", &type_handler_slong, INVISIBLE_SYSTEM,
- new (thd->mem_root)Item_int(thd, 9));
- });
- DBUG_EXECUTE_IF("test_completely_invisible",{
- mysql_add_invisible_field(thd, &alter_info->create_list,
- "invisible", &type_handler_slong, INVISIBLE_FULL,
- new (thd->mem_root)Item_int(thd, 9));
- });
- DBUG_EXECUTE_IF("test_invisible_index",{
- LEX_CSTRING temp;
- temp.str= "invisible";
- temp.length= strlen("invisible");
- mysql_add_invisible_index(thd, &alter_info->key_list
- , &temp, Key::MULTIPLE);
- });
LEX_CSTRING* connect_string = &create_info->connect_string;
if (connect_string->length != 0 &&
connect_string->length > CONNECT_STRING_MAXLEN &&
@@ -2805,42 +2846,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(TRUE);
}
+
for (field_no=0; (sql_field=it++) ; field_no++)
{
- /* Virtual fields are always NULL */
- if (sql_field->vcol_info)
- sql_field->flags&= ~NOT_NULL_FLAG;
-
- /*
- Initialize length from its original value (number of characters),
- which was set in the parser. This is necessary if we're
- executing a prepared statement for the second time.
- */
- sql_field->length= sql_field->char_length;
-
- if (sql_field->bulk_alter(&dattr, &battr))
- DBUG_RETURN(true);
-
- if (sql_field->prepare_stage1(thd, thd->mem_root,
- file, file->ha_table_flags(),
- &dattr))
- DBUG_RETURN(true);
-
- DBUG_ASSERT(sql_field->charset);
+ if (!(sql_field->flags & NOT_NULL_FLAG))
+ null_fields++;
if (sql_field->real_field_type() == MYSQL_TYPE_BIT &&
file->ha_table_flags() & HA_CAN_BIT_FIELD)
total_uneven_bit_length+= sql_field->length & 7;
- if (!(sql_field->flags & NOT_NULL_FLAG))
- null_fields++;
-
- if (check_column_name(sql_field->field_name.str))
- {
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name.str);
- DBUG_RETURN(TRUE);
- }
-
/* Check if we have used the same field name before */
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{
@@ -3829,6 +3844,49 @@ without_overlaps_err:
DBUG_RETURN(FALSE);
}
+
+/*
+ Preparation for table creation
+
+ SYNOPSIS
+ mysql_prepare_create_table()
+ thd Thread object.
+ create_info Create information (like MAX_ROWS).
+ alter_info List of columns and indexes to create
+ db_options INOUT Table options (like HA_OPTION_PACK_RECORD).
+ file The handler for the new table.
+ key_info_buffer OUT An array of KEY structs for the indexes.
+ key_count OUT The number of elements in the array.
+ create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE,
+ C_CREATE_SELECT, C_ASSISTED_DISCOVERY
+
+ DESCRIPTION
+ Prepares the table and key structures for table creation.
+
+ NOTES
+ sets create_info->varchar if the table has a varchar
+
+ RETURN VALUES
+ FALSE OK
+ TRUE error
+*/
+
+static int
+mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
+ Alter_info *alter_info, uint *db_options,
+ handler *file, KEY **key_info_buffer,
+ uint *key_count, int create_table_mode,
+ const LEX_CSTRING db,
+ const LEX_CSTRING table_name)
+{
+ return mysql_prepare_create_table_stage1(thd, create_info, alter_info) ||
+ mysql_prepare_create_table_finalize(thd, create_info, alter_info,
+ db_options, file, key_info_buffer,
+ key_count, create_table_mode,
+ db, table_name);
+}
+
+
/**
check comment length of table, column, index and partition
@@ -3957,7 +4015,8 @@ bool Column_definition::prepare_blob_field(THD *thd)
bool Column_definition::sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root)
{
const Column_derived_attributes dattr(thd->variables.collation_database);
- return prepare_stage1(thd, mem_root, NULL, HA_CAN_GEOMETRY, &dattr) ||
+ return prepare_stage1(thd, mem_root,
+ COLUMN_DEFINITION_ROUTINE_LOCAL, &dattr) ||
prepare_stage2(NULL, HA_CAN_GEOMETRY);
}
@@ -4052,6 +4111,9 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db,
DBUG_RETURN(NULL);
}
+ if (mysql_prepare_create_table_stage1(thd, create_info, alter_info))
+ DBUG_RETURN(NULL);
+
db_options= create_info->table_options_with_row_type();
if (unlikely(!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root,
@@ -4268,9 +4330,10 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db,
}
#endif
- if (mysql_prepare_create_table(thd, create_info, alter_info, &db_options,
- file, key_info, key_count,
- create_table_mode, db, table_name))
+ if (mysql_prepare_create_table_finalize(thd, create_info,
+ alter_info, &db_options,
+ file, key_info, key_count,
+ create_table_mode, db, table_name))
goto err;
create_info->table_options=db_options;
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index 3759c0ba02f..213de62705f 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -3008,8 +3008,7 @@ bool Type_handler::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3022,8 +3021,7 @@ bool Type_handler_null::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3037,8 +3035,7 @@ bool Type_handler_row::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3052,8 +3049,7 @@ bool Type_handler_temporal_result::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3067,8 +3063,7 @@ bool Type_handler_numeric::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3081,8 +3076,7 @@ bool Type_handler_newdecimal::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
@@ -3096,28 +3090,26 @@ bool Type_handler_bit::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
{
def->charset= &my_charset_numeric;
- return def->prepare_stage1_bit(thd, mem_root, file, table_flags);
+ return def->prepare_stage1_bit(thd, mem_root);
}
bool Type_handler_typelib::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
{
return def->prepare_charset_for_string(derived_attr) ||
- def->prepare_stage1_typelib(thd, mem_root, file, table_flags);
+ def->prepare_stage1_typelib(thd, mem_root, type);
}
@@ -3125,14 +3117,13 @@ bool Type_handler_string_result::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const
{
return def->prepare_charset_for_string(derived_attr) ||
- def->prepare_stage1_string(thd, mem_root, file, table_flags);
+ def->prepare_stage1_string(thd, mem_root);
}
@@ -3343,10 +3334,11 @@ bool Type_handler_bit::
handler *file,
ulonglong table_flags) const
{
- /*
- We have sql_field->pack_flag already set here, see
- mysql_prepare_create_table().
- */
+ if (!(table_flags & HA_CAN_BIT_FIELD))
+ {
+ def->pack_flag|= FIELDFLAG_TREAT_BIT_AS_CHAR;
+ def->create_length_to_internal_length_bit();
+ }
return false;
}
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 741e0c9bb96..d931c7ffb6d 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -3962,8 +3962,7 @@ public:
virtual bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const;
@@ -4441,8 +4440,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -4756,8 +4754,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -5310,8 +5307,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -5414,8 +5410,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -5947,8 +5942,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -6791,8 +6785,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -6849,8 +6842,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
@@ -7286,8 +7278,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
diff --git a/sql/sql_type_fixedbin.h b/sql/sql_type_fixedbin.h
index 223bf2cf398..c1be1c9ccba 100644
--- a/sql/sql_type_fixedbin.h
+++ b/sql/sql_type_fixedbin.h
@@ -382,8 +382,8 @@ public:
}
bool Column_definition_prepare_stage1(THD *thd, MEM_ROOT *mem_root,
- Column_definition *def, handler *file,
- ulonglong table_flags,
+ Column_definition *def,
+ column_definition_type_t type,
const Column_derived_attributes *derived_attr)
const override
{
diff --git a/sql/sql_type_geom.cc b/sql/sql_type_geom.cc
index 5732ae47217..3bdc34b4d65 100644
--- a/sql/sql_type_geom.cc
+++ b/sql/sql_type_geom.cc
@@ -280,8 +280,7 @@ bool Type_handler_geometry::
Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *def,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr) const
{
diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h
index 3bc25808bc3..db951297519 100644
--- a/sql/sql_type_geom.h
+++ b/sql/sql_type_geom.h
@@ -108,8 +108,7 @@ public:
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
- handler *file,
- ulonglong table_flags,
+ column_definition_type_t type,
const Column_derived_attributes
*derived_attr)
const override;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 4173d6d82ec..ff1d70e7f8e 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -45,6 +45,9 @@
#include "sql_insert.h" // For vers_insert_history_row() that may be
// needed for System Versioning.
+#ifdef WITH_WSREP
+#include "wsrep_mysqld.h"
+#endif
/**
True if the table's input and output record buffers are comparable using
@@ -197,22 +200,11 @@ static bool check_fields(THD *thd, TABLE_LIST *table, List<Item> &items,
return true;
}
- DBUG_ASSERT(thd->lex->sql_command == SQLCOM_UPDATE);
- for (List_iterator_fast<Item> it(items); (item=it++);)
- {
- Field *f= item->field_for_view_update()->field;
- vers_select_conds_t &period= table->period_conditions;
- if (period.field_start->field == f || period.field_end->field == f)
- {
- my_error(ER_PERIOD_COLUMNS_UPDATED, MYF(0),
- item->name.str, period.name.str);
- return true;
- }
- }
}
return FALSE;
}
+
bool TABLE::vers_check_update(List<Item> &items)
{
List_iterator<Item> it(items);
@@ -339,36 +331,25 @@ int cut_fields_for_portion_of_time(THD *thd, TABLE *table,
return res;
}
-/*
- Process usual UPDATE
-
- SYNOPSIS
- mysql_update()
- thd thread handler
- fields fields for update
- values values of fields for update
- conds WHERE clause expression
- order_num number of elemen in ORDER BY clause
- order ORDER BY clause list
- limit limit clause
+/**
+ @brief Special handling of single-table updates after prepare phase
- RETURN
- 0 - OK
- 2 - privilege check and openning table passed, but we need to convert to
- multi-update because of view substitution
- 1 - error
+ @param thd global context the processed statement
+ @returns false on success, true on error
*/
-int mysql_update(THD *thd,
- TABLE_LIST *table_list,
- List<Item> &fields,
- List<Item> &values,
- COND *conds,
- uint order_num, ORDER *order,
- ha_rows limit,
- bool ignore,
- ha_rows *found_return, ha_rows *updated_return)
+bool Sql_cmd_update::update_single_table(THD *thd)
{
+ SELECT_LEX_UNIT *unit = &lex->unit;
+ SELECT_LEX *select_lex= unit->first_select();
+ TABLE_LIST *const table_list = select_lex->get_table_list();
+ List<Item> *fields= &select_lex->item_list;
+ List<Item> *values= &lex->value_list;
+ COND *conds= select_lex->where_cond_after_prepare;
+ ORDER *order= select_lex->order_list.first;
+ ha_rows limit= unit->lim.get_select_limit();
+ bool ignore= lex->ignore;
+
bool using_limit= limit != HA_POS_ERROR;
bool safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES)
&& !thd->lex->describe;
@@ -380,76 +361,38 @@ int mysql_update(THD *thd,
ha_rows dup_key_found;
bool need_sort= TRUE;
bool reverse= FALSE;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- privilege_t want_privilege(NO_ACL);
-#endif
- uint table_count= 0;
ha_rows updated, updated_or_same, found;
key_map old_covering_keys;
TABLE *table;
SQL_SELECT *select= NULL;
SORT_INFO *file_sort= 0;
READ_RECORD info;
- SELECT_LEX *select_lex= thd->lex->first_select_lex();
ulonglong id;
List<Item> all_fields;
killed_state killed_status= NOT_KILLED;
bool has_triggers, binlog_is_row, do_direct_update= FALSE;
Update_plan query_plan(thd->mem_root);
Explain_update *explain;
- TABLE_LIST *update_source_table;
query_plan.index= MAX_KEY;
query_plan.using_filesort= FALSE;
// For System Versioning (may need to insert new fields to a table).
ha_rows rows_inserted= 0;
- DBUG_ENTER("mysql_update");
-
- create_explain_query(thd->lex, thd->mem_root);
- if (open_tables(thd, &table_list, &table_count, 0))
- DBUG_RETURN(1);
-
- /* Prepare views so they are handled correctly */
- if (mysql_handle_derived(thd->lex, DT_INIT))
- DBUG_RETURN(1);
-
- if (table_list->has_period() && table_list->is_view_or_derived())
- {
- my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
- DBUG_RETURN(TRUE);
- }
-
- if (((update_source_table=unique_table(thd, table_list,
- table_list->next_global, 0)) ||
- table_list->is_multitable()))
- {
- DBUG_ASSERT(update_source_table || table_list->view != 0);
- DBUG_PRINT("info", ("Switch to multi-update"));
- /* pass counter value */
- thd->lex->table_count_update= table_count;
- if (thd->lex->period_conditions.is_set())
- {
- my_error(ER_NOT_SUPPORTED_YET, MYF(0),
- "updating and querying the same temporal periods table");
-
- DBUG_RETURN(1);
- }
+ DBUG_ENTER("Sql_cmd_update::update_single_table");
- /* convert to multiupdate */
- DBUG_RETURN(2);
- }
- if (lock_tables(thd, table_list, table_count, 0))
- DBUG_RETURN(1);
+ THD_STAGE_INFO(thd, stage_init_update);
- (void) read_statistics_for_tables_if_needed(thd, table_list);
+ thd->table_map_for_update= 0;
- THD_STAGE_INFO(thd, stage_init_update);
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
DBUG_RETURN(1);
if (table_list->handle_derived(thd->lex, DT_PREPARE))
DBUG_RETURN(1);
+ if (setup_ftfuncs(select_lex))
+ DBUG_RETURN(1);
+
table= table_list->table;
if (!table_list->single_table_updatable())
@@ -458,89 +401,26 @@ int mysql_update(THD *thd,
DBUG_RETURN(1);
}
- /* Calculate "table->covering_keys" based on the WHERE */
- table->covering_keys= table->s->keys_in_use;
table->opt_range_keys.clear_all();
query_plan.select_lex= thd->lex->first_select_lex();
query_plan.table= table;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* Force privilege re-checking for views after they have been opened. */
- want_privilege= (table_list->view ? UPDATE_ACL :
- table_list->grant.want_privilege);
-#endif
thd->lex->promote_select_describe_flag_if_needed();
- if (mysql_prepare_update(thd, table_list, &conds, order_num, order))
- DBUG_RETURN(1);
-
- if (table_list->has_period())
- {
- if (!table_list->period_conditions.start.item->const_item()
- || !table_list->period_conditions.end.item->const_item())
- {
- my_error(ER_NOT_CONSTANT_EXPRESSION, MYF(0), "FOR PORTION OF");
- DBUG_RETURN(true);
- }
- table->no_cache= true;
- }
-
old_covering_keys= table->covering_keys; // Keys used in WHERE
- /* Check the fields we are going to modify */
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= table->grant.want_privilege= want_privilege;
- table_list->register_want_access(want_privilege);
-#endif
- /* 'Unfix' fields to allow correct marking by the setup_fields function. */
- if (table_list->is_view())
- unfix_fields(fields);
- if (setup_fields_with_no_wrap(thd, Ref_ptr_array(),
- fields, MARK_COLUMNS_WRITE, 0, 0))
- DBUG_RETURN(1); /* purecov: inspected */
- if (check_fields(thd, table_list, fields, table_list->view))
- {
- DBUG_RETURN(1);
- }
- bool has_vers_fields= table->vers_check_update(fields);
- if (check_key_in_view(thd, table_list))
- {
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE");
- DBUG_RETURN(1);
- }
+ bool has_vers_fields= table->vers_check_update(*fields);
if (table->default_field)
table->mark_default_fields_for_write(false);
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* Check values */
- table_list->grant.want_privilege= table->grant.want_privilege=
- (SELECT_ACL & ~table->grant.privilege);
-#endif
- if (setup_fields(thd, Ref_ptr_array(), values, MARK_COLUMNS_READ, 0, NULL, 0))
- {
- free_underlaid_joins(thd, select_lex);
- DBUG_RETURN(1); /* purecov: inspected */
- }
-
- if (table_list->table->check_assignability_explicit_fields(fields, values,
- ignore))
- DBUG_RETURN(true);
-
- if (check_unique_table(thd, table_list))
- DBUG_RETURN(TRUE);
-
- switch_to_nullable_trigger_fields(fields, table);
- switch_to_nullable_trigger_fields(values, table);
+ switch_to_nullable_trigger_fields(*fields, table);
+ switch_to_nullable_trigger_fields(*values, table);
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them */
if (select_lex->optimize_unflattened_subqueries(false))
DBUG_RETURN(TRUE);
- if (select_lex->inner_refs_list.elements &&
- fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
- DBUG_RETURN(1);
-
if (conds)
{
Item::cond_result cond_value;
@@ -782,9 +662,9 @@ int mysql_update(THD *thd,
}
if (use_direct_update &&
- !table->file->info_push(INFO_KIND_UPDATE_FIELDS, &fields) &&
- !table->file->info_push(INFO_KIND_UPDATE_VALUES, &values) &&
- !table->file->direct_update_rows_init(&fields))
+ !table->file->info_push(INFO_KIND_UPDATE_FIELDS, fields) &&
+ !table->file->info_push(INFO_KIND_UPDATE_VALUES, values) &&
+ !table->file->direct_update_rows_init(fields))
{
do_direct_update= TRUE;
@@ -1033,7 +913,7 @@ update_begin:
cut_fields_for_portion_of_time(thd, table,
table_list->period_conditions);
- if (fill_record_n_invoke_before_triggers(thd, table, fields, values, 0,
+ if (fill_record_n_invoke_before_triggers(thd, table, *fields, *values, 0,
TRG_EVENT_UPDATE))
break; /* purecov: inspected */
@@ -1366,9 +1246,9 @@ update_end:
thd->lex->current_select->save_leaf_tables(thd);
thd->lex->current_select->first_cond_optimization= 0;
}
- *found_return= found;
- *updated_return= updated;
-
+ ((multi_update *)result)->set_found(found);
+ ((multi_update *)result)->set_updated(updated);
+
if (unlikely(thd->lex->analyze_stmt))
goto emit_explain_and_leave;
@@ -1400,75 +1280,6 @@ emit_explain_and_leave:
DBUG_RETURN((err2 || thd->is_error()) ? 1 : 0);
}
-/*
- Prepare items in UPDATE statement
-
- SYNOPSIS
- mysql_prepare_update()
- thd - thread handler
- table_list - global/local table list
- conds - conditions
- order_num - number of ORDER BY list entries
- order - ORDER BY clause list
-
- RETURN VALUE
- FALSE OK
- TRUE error
-*/
-bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
- Item **conds, uint order_num, ORDER *order)
-{
- Item *fake_conds= 0;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE *table= table_list->table;
-#endif
- List<Item> all_fields;
- SELECT_LEX *select_lex= thd->lex->first_select_lex();
- DBUG_ENTER("mysql_prepare_update");
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= table->grant.want_privilege=
- (SELECT_ACL & ~table->grant.privilege);
- table_list->register_want_access(SELECT_ACL);
-#endif
-
- thd->lex->allow_sum_func.clear_all();
-
- if (table_list->has_period() &&
- select_lex->period_setup_conds(thd, table_list))
- DBUG_RETURN(true);
-
- DBUG_ASSERT(table_list->table);
- // conds could be cached from previous SP call
- DBUG_ASSERT(!table_list->vers_conditions.need_setup() ||
- !*conds || thd->stmt_arena->is_stmt_execute());
- if (select_lex->vers_setup_conds(thd, table_list))
- DBUG_RETURN(TRUE);
-
- *conds= select_lex->where;
-
- /*
- We do not call DT_MERGE_FOR_INSERT because it has no sense for simple
- (not multi-) update
- */
- if (mysql_handle_derived(thd->lex, DT_PREPARE))
- DBUG_RETURN(TRUE);
-
- if (setup_tables_and_check_access(thd, &select_lex->context,
- &select_lex->top_join_list, table_list,
- select_lex->leaf_tables,
- FALSE, UPDATE_ACL, SELECT_ACL, TRUE) ||
- setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
- select_lex->setup_ref_array(thd, order_num) ||
- setup_order(thd, select_lex->ref_pointer_array,
- table_list, all_fields, all_fields, order) ||
- setup_ftfuncs(select_lex))
- DBUG_RETURN(TRUE);
-
-
- select_lex->fix_prepare_information(thd, conds, &fake_conds);
- DBUG_RETURN(FALSE);
-}
/**
Check that we are not using table that we are updating in a sub select
@@ -1696,15 +1507,6 @@ static bool multi_update_check_table_access(THD *thd, TABLE_LIST *table,
}
-class Multiupdate_prelocking_strategy : public DML_prelocking_strategy
-{
- bool done;
- bool has_prelocking_list;
-public:
- void reset(THD *thd);
- bool handle_end(THD *thd);
-};
-
void Multiupdate_prelocking_strategy::reset(THD *thd)
{
done= false;
@@ -1734,7 +1536,13 @@ bool Multiupdate_prelocking_strategy::handle_end(THD *thd)
mysql_handle_derived(lex, DT_PREPARE))
DBUG_RETURN(1);
- /*
+ if (table_list->has_period() && table_list->is_view_or_derived())
+ {
+ my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
+ DBUG_RETURN(TRUE);
+ }
+
+ /*
setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
second time, but this call will do nothing (there are check for second
call in setup_tables()).
@@ -1745,6 +1553,10 @@ bool Multiupdate_prelocking_strategy::handle_end(THD *thd)
FALSE, UPDATE_ACL, SELECT_ACL, TRUE))
DBUG_RETURN(1);
+ if (table_list->has_period() &&
+ select_lex->period_setup_conds(thd, table_list))
+ DBUG_RETURN(true);
+
List<Item> *fields= &lex->first_select_lex()->item_list;
if (setup_fields_with_no_wrap(thd, Ref_ptr_array(),
*fields, MARK_COLUMNS_WRITE, 0, 0))
@@ -1853,153 +1665,6 @@ bool Multiupdate_prelocking_strategy::handle_end(THD *thd)
DBUG_RETURN(0);
}
-/*
- make update specific preparation and checks after opening tables
-
- SYNOPSIS
- mysql_multi_update_prepare()
- thd thread handler
-
- RETURN
- FALSE OK
- TRUE Error
-*/
-
-int mysql_multi_update_prepare(THD *thd)
-{
- LEX *lex= thd->lex;
- TABLE_LIST *table_list= lex->query_tables;
- TABLE_LIST *tl;
- Multiupdate_prelocking_strategy prelocking_strategy;
- uint table_count= lex->table_count_update;
- DBUG_ENTER("mysql_multi_update_prepare");
-
- /*
- Open tables and create derived ones, but do not lock and fill them yet.
-
- During prepare phase acquire only S metadata locks instead of SW locks to
- keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE
- and global read lock.
-
- Don't evaluate any subqueries even if constant, because
- tables aren't locked yet.
- */
- lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
- if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
- {
- if (open_tables(thd, &table_list, &table_count,
- thd->stmt_arena->is_stmt_prepare() ? MYSQL_OPEN_FORCE_SHARED_MDL : 0,
- &prelocking_strategy))
- DBUG_RETURN(TRUE);
- }
- else
- {
- /* following need for prepared statements, to run next time multi-update */
- thd->lex->sql_command= SQLCOM_UPDATE_MULTI;
- prelocking_strategy.reset(thd);
- if (prelocking_strategy.handle_end(thd))
- DBUG_RETURN(TRUE);
- }
-
- /* now lock and fill tables */
- if (!thd->stmt_arena->is_stmt_prepare() &&
- lock_tables(thd, table_list, table_count, 0))
- DBUG_RETURN(TRUE);
-
- lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
-
- (void) read_statistics_for_tables_if_needed(thd, table_list);
- /* @todo: downgrade the metadata locks here. */
-
- /*
- Check that we are not using table that we are updating, but we should
- skip all tables of UPDATE SELECT itself
- */
- lex->first_select_lex()->exclude_from_table_unique_test= TRUE;
- /* We only need SELECT privilege for columns in the values list */
- List_iterator<TABLE_LIST> ti(lex->first_select_lex()->leaf_tables);
- while ((tl= ti++))
- {
- if (tl->is_jtbm())
- continue;
- TABLE *table= tl->table;
- TABLE_LIST *tlist;
- if (!(tlist= tl->top_table())->derived)
- {
- tlist->grant.want_privilege=
- (SELECT_ACL & ~tlist->grant.privilege);
- table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege);
- }
- DBUG_PRINT("info", ("table: %s want_privilege: %llx", tl->alias.str,
- (longlong) table->grant.want_privilege));
- }
- /*
- Set exclude_from_table_unique_test value back to FALSE. It is needed for
- further check in multi_update::prepare whether to use record cache.
- */
- lex->first_select_lex()->exclude_from_table_unique_test= FALSE;
-
- if (lex->save_prep_leaf_tables())
- DBUG_RETURN(TRUE);
-
- DBUG_RETURN (FALSE);
-}
-
-
-/*
- Setup multi-update handling and call SELECT to do the join
-*/
-
-bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields,
- List<Item> *values, COND *conds, ulonglong options,
- enum enum_duplicates handle_duplicates,
- bool ignore, SELECT_LEX_UNIT *unit,
- SELECT_LEX *select_lex, multi_update **result)
-{
- bool res;
- DBUG_ENTER("mysql_multi_update");
-
- if (!(*result= new (thd->mem_root) multi_update(thd, table_list,
- &thd->lex->first_select_lex()->leaf_tables,
- fields, values, handle_duplicates, ignore)))
- {
- DBUG_RETURN(TRUE);
- }
-
- if ((*result)->init(thd))
- DBUG_RETURN(1);
-
- thd->abort_on_warning= !ignore && thd->is_strict_mode();
- List<Item> total_list;
-
- if (setup_tables(thd, &select_lex->context, &select_lex->top_join_list,
- table_list, select_lex->leaf_tables, FALSE, FALSE))
- DBUG_RETURN(1);
-
- if (select_lex->vers_setup_conds(thd, table_list))
- DBUG_RETURN(1);
-
- res= mysql_select(thd,
- table_list, total_list, conds,
- select_lex->order_list.elements,
- select_lex->order_list.first, NULL, NULL, NULL,
- options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
- OPTION_SETUP_TABLES_DONE,
- *result, unit, select_lex);
-
- DBUG_PRINT("info",("res: %d report_error: %d", res, (int) thd->is_error()));
- res|= thd->is_error();
- if (unlikely(res))
- (*result)->abort_result_set();
- else
- {
- if (thd->lex->describe || thd->lex->analyze_stmt)
- res= thd->lex->explain->send_explain(thd);
- }
- thd->abort_on_warning= 0;
- DBUG_RETURN(res);
-}
-
multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
List<TABLE_LIST> *leaves_list,
@@ -2035,6 +1700,19 @@ bool multi_update::init(THD *thd)
}
+bool multi_update::init_for_single_table(THD *thd)
+{
+ List_iterator_fast<TABLE_LIST> li(*leaves);
+ TABLE_LIST *tbl;
+ while ((tbl =li++))
+ {
+ if (updated_leaves.push_back(tbl, thd->mem_root))
+ return true;
+ }
+ return false;
+}
+
+
/*
Connect fields with tables and create list of tables that are updated
*/
@@ -2110,7 +1788,8 @@ int multi_update::prepare(List<Item> &not_used_values,
{
table->read_set= &table->def_read_set;
bitmap_union(table->read_set, &table->tmp_set);
- table->file->prepare_for_insert(1);
+ if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_PREPARE))
+ table->file->prepare_for_insert(1);
}
}
if (unlikely(error))
@@ -2799,6 +2478,8 @@ int multi_update::do_updates()
table = cur_table->table;
if (table == table_to_update)
continue; // Already updated
+ if (table->file->pushed_rowid_filter)
+ table->file->disable_pushed_rowid_filter();
org_updated= updated;
tmp_table= tmp_tables[cur_table->shared];
tmp_table->file->extra(HA_EXTRA_CACHE); // Change to read cache
@@ -2993,7 +2674,8 @@ int multi_update::do_updates()
check_opt_it.rewind();
while (TABLE *tbl= check_opt_it++)
tbl->file->ha_rnd_end();
-
+ if (table->file->save_pushed_rowid_filter)
+ table->file->enable_pushed_rowid_filter();
}
DBUG_RETURN(0);
@@ -3004,6 +2686,8 @@ err:
}
err2:
+ if (table->file->save_pushed_rowid_filter)
+ table->file->enable_pushed_rowid_filter();
if (table->file->inited)
(void) table->file->ha_rnd_end();
if (tmp_table->file->inited)
@@ -3132,3 +2816,263 @@ bool multi_update::send_eof()
}
DBUG_RETURN(FALSE);
}
+
+
+/**
+ @brief Check whether conversion to multi-table update is prohibited
+
+ @param thd global context the processed statement
+ @returns true if conversion is prohibited, false otherwise
+
+ @todo
+ Introduce handler level flag for storage engines that would prohibit
+ such conversion for any single-table update.
+*/
+
+bool Sql_cmd_update::processing_as_multitable_update_prohibited(THD *thd)
+{
+ SELECT_LEX *const select_lex = thd->lex->first_select_lex();
+ return
+ (select_lex->order_list.elements &&
+ select_lex->limit_params.select_limit);
+}
+
+
+/**
+ @brief Perform precheck of table privileges for update statements
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+*/
+
+bool Sql_cmd_update::precheck(THD *thd)
+{
+ if (!multitable)
+ {
+ if (update_precheck(thd, lex->query_tables))
+ return true;
+ }
+ else
+ {
+ if (multi_update_precheck(thd, lex->query_tables))
+ return true;
+ }
+
+#ifdef WITH_WSREP
+ WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
+#endif
+
+ return false;
+
+#ifdef WITH_WSREP
+wsrep_error_label:
+#endif
+ return true;
+}
+
+
+/**
+ @brief Perform context analysis for update statements
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+
+ @note
+ The main bulk of the context analysis actions for and update statement
+ is performed by a call of JOIN::prepare().
+*/
+
+bool Sql_cmd_update::prepare_inner(THD *thd)
+{
+ JOIN *join;
+ int err= 0;
+ SELECT_LEX *const select_lex = thd->lex->first_select_lex();
+ TABLE_LIST *const table_list = select_lex->get_table_list();
+ ulonglong select_options= select_lex->options;
+ bool free_join= 1;
+ DBUG_ENTER("Sql_cmd_update::prepare_inner");
+
+ (void) read_statistics_for_tables_if_needed(thd, table_list);
+
+ THD_STAGE_INFO(thd, stage_init_update);
+
+ if (!multitable)
+ {
+ if (mysql_handle_derived(lex, DT_INIT))
+ DBUG_RETURN(TRUE);
+ }
+
+ if (table_list->has_period() && table_list->is_view_or_derived())
+ {
+ my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
+ DBUG_RETURN(TRUE);
+ }
+
+ if (!multitable)
+ {
+ TABLE_LIST *update_source_table= 0;
+
+ if (((update_source_table=unique_table(thd, table_list,
+ table_list->next_global, 0)) ||
+ table_list->is_multitable()))
+ {
+ DBUG_ASSERT(update_source_table || table_list->view != 0);
+ if (thd->lex->period_conditions.is_set())
+ {
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0),
+ "updating and querying the same temporal periods table");
+ DBUG_RETURN(TRUE);
+ }
+ if (!table_list->is_multitable() &&
+ !processing_as_multitable_update_prohibited(thd))
+ multitable= true;
+ }
+ }
+
+ if(!multitable)
+ {
+ if (table_list->is_view_or_derived() &&
+ select_lex->leaf_tables.elements > 1)
+ multitable = true;
+ }
+
+ if (!multitable)
+ {
+ if (lex->ignore)
+ lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UPDATE_IGNORE);
+ }
+
+ if (!(result= new (thd->mem_root) multi_update(thd, table_list,
+ &select_lex->leaf_tables,
+ &select_lex->item_list,
+ &lex->value_list,
+ lex->duplicates,
+ lex->ignore)))
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ if (((multi_update *)result)->init(thd))
+ DBUG_RETURN(TRUE);
+
+ if (setup_tables(thd, &select_lex->context, &select_lex->top_join_list,
+ table_list, select_lex->leaf_tables, false, false))
+ DBUG_RETURN(TRUE);
+
+ if (select_lex->vers_setup_conds(thd, table_list))
+ DBUG_RETURN(TRUE);
+
+ {
+ if (thd->lex->describe)
+ select_options|= SELECT_DESCRIBE;
+
+ /*
+ When in EXPLAIN, delay deleting the joins so that they are still
+ available when we're producing EXPLAIN EXTENDED warning text.
+ */
+ if (select_options & SELECT_DESCRIBE)
+ free_join= 0;
+
+ select_options|=
+ SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE;
+
+ if (!(join= new (thd->mem_root) JOIN(thd, select_lex->item_list,
+ select_options, result)))
+ DBUG_RETURN(TRUE);
+ THD_STAGE_INFO(thd, stage_init);
+ select_lex->join= join;
+ thd->lex->used_tables=0;
+ select_lex->item_list_usage= MARK_COLUMNS_WRITE;
+ if ((err= join->prepare(table_list, select_lex->where,
+ select_lex->order_list.elements,
+ select_lex->order_list.first,
+ false, NULL, NULL, NULL,
+ select_lex, &lex->unit)))
+ {
+ goto err;
+ }
+ if (!multitable &&
+ select_lex->sj_subselects.elements)
+ multitable= true;
+ }
+
+ if (table_list->has_period())
+ {
+ Item *item;
+ for (List_iterator_fast<Item> it(select_lex->item_list); (item=it++);)
+ {
+ Field *f= item->field_for_view_update()->field;
+ vers_select_conds_t &period= table_list->period_conditions;
+ if (period.field_start->field == f || period.field_end->field == f)
+ {
+ my_error(ER_PERIOD_COLUMNS_UPDATED, MYF(0),
+ item->name.str, period.name.str);
+ DBUG_RETURN(true);
+ }
+ }
+
+ if (!table_list->period_conditions.start.item->const_item()
+ || !table_list->period_conditions.end.item->const_item())
+ {
+ my_error(ER_NOT_CONSTANT_EXPRESSION, MYF(0), "FOR PORTION OF");
+ DBUG_RETURN(true);
+ }
+ table_list->table->no_cache= true;
+ }
+
+
+ free_join= false;
+
+err:
+
+ if (free_join)
+ {
+ THD_STAGE_INFO(thd, stage_end);
+ err|= (int)(select_lex->cleanup());
+ DBUG_RETURN(err || thd->is_error());
+ }
+ DBUG_RETURN(err);
+
+}
+
+
+/**
+ @brief Perform optimization and execution actions needed for updates
+
+ @param thd global context the processed statement
+ @returns false on success, true on error
+*/
+
+bool Sql_cmd_update::execute_inner(THD *thd)
+{
+ bool res= 0;
+
+ thd->get_stmt_da()->reset_current_row_for_warning(1);
+ if (!multitable)
+ res= update_single_table(thd);
+ else
+ {
+ thd->abort_on_warning= !thd->lex->ignore && thd->is_strict_mode();
+ res= Sql_cmd_dml::execute_inner(thd);
+ }
+
+ res|= thd->is_error();
+ if (multitable)
+ {
+ if (unlikely(res))
+ result->abort_result_set();
+ else
+ {
+ if (thd->lex->describe || thd->lex->analyze_stmt)
+ res= thd->lex->explain->send_explain(thd);
+ }
+ }
+
+ if (result)
+ {
+ res= false;
+ delete result;
+ }
+
+ return res;
+}
diff --git a/sql/sql_update.h b/sql/sql_update.h
index 65e44d112a4..bd7d58cf97d 100644
--- a/sql/sql_update.h
+++ b/sql/sql_update.h
@@ -17,6 +17,8 @@
#define SQL_UPDATE_INCLUDED
#include "sql_class.h" /* enum_duplicates */
+#include "sql_cmd.h" // Sql_cmd_dml
+#include "sql_base.h"
class Item;
struct TABLE_LIST;
@@ -25,20 +27,83 @@ class THD;
typedef class st_select_lex SELECT_LEX;
typedef class st_select_lex_unit SELECT_LEX_UNIT;
-bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
- Item **conds, uint order_num, ORDER *order);
bool check_unique_table(THD *thd, TABLE_LIST *table_list);
-int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
- List<Item> &values,COND *conds,
- uint order_num, ORDER *order, ha_rows limit,
- bool ignore, ha_rows *found_return, ha_rows *updated_return);
-bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
- List<Item> *fields, List<Item> *values,
- COND *conds, ulonglong options,
- enum enum_duplicates handle_duplicates, bool ignore,
- SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex,
- multi_update **result);
bool records_are_comparable(const TABLE *table);
bool compare_record(const TABLE *table);
+/**
+ @class Sql_cmd_update - class used for any UPDATE statements
+
+ This class is derived from Sql_cmd_dml and contains implementations
+ for abstract virtual function of the latter such as precheck() and
+ prepare_inner(). It also overrides the implementation of execute_inner()
+ providing a special handling for single-table update statements that
+ are not converted to multi-table updates.
+ The class provides an object of the Multiupdate_prelocking_strategy class
+ for the virtual function get_dml_prelocking_strategy().
+*/
+class Sql_cmd_update final : public Sql_cmd_dml
+{
+public:
+ Sql_cmd_update(bool multitable_arg)
+ : orig_multitable(multitable_arg), multitable(multitable_arg)
+ {}
+
+ enum_sql_command sql_command_code() const override
+ {
+ return orig_multitable ? SQLCOM_UPDATE_MULTI : SQLCOM_UPDATE;
+ }
+
+ DML_prelocking_strategy *get_dml_prelocking_strategy()
+ {
+ return &multiupdate_prelocking_strategy;
+ }
+
+ bool processing_as_multitable_update_prohibited(THD *thd);
+
+ bool is_multitable() { return multitable; }
+
+ void set_as_multitable() { multitable= true; }
+
+protected:
+ /**
+ @brief Perform precheck of table privileges for update statements
+ */
+ bool precheck(THD *thd) override;
+
+ /**
+ @brief Perform context analysis for update statements
+ */
+ bool prepare_inner(THD *thd) override;
+
+ /**
+ @brief Perform optimization and execution actions needed for updates
+ */
+ bool execute_inner(THD *thd) override;
+
+private:
+
+ /**
+ @brief Special handling of single-table updates after prepare phase
+ */
+ bool update_single_table(THD *thd);
+
+ /* Original value of the 'multitable' flag set by constructor */
+ const bool orig_multitable;
+
+ /*
+ True if the statement is a multi-table update or converted to such.
+ For a single-table update this flag is set to true if the statement
+ is supposed to be converted to multi-table update.
+ */
+ bool multitable;
+
+ /* The prelocking strategy used when opening the used tables */
+ Multiupdate_prelocking_strategy multiupdate_prelocking_strategy;
+
+ public:
+ /* The list of the updating expressions used in the set clause */
+ List<Item> *update_value_list;
+};
+
#endif /* SQL_UPDATE_INCLUDED */
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 8c1a2d60680..b9b269933bb 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -69,6 +69,8 @@
#include "my_base.h"
#include "sql_type_json.h"
#include "json_table.h"
+#include "sql_update.h"
+#include "sql_delete.h"
/* this is to get the bison compilation windows warnings out */
#ifdef _MSC_VER
@@ -1683,7 +1685,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
opt_mi_check_type opt_to mi_check_types
table_to_table_list table_to_table opt_table_list opt_as
handler_rkey_function handler_read_or_scan
- single_multi table_wild_list table_wild_one opt_wild
+ single_multi opt_wild
opt_and
select_var_list select_var_list_init help
opt_extended_describe shutdown
@@ -13263,9 +13265,14 @@ update:
opt_low_priority opt_ignore update_table_list
SET update_list
{
+ bool is_multiupdate= false;
+ LEX *lex= Lex;
SELECT_LEX *slex= Lex->first_select_lex();
if (slex->table_list.elements > 1)
+ {
Lex->sql_command= SQLCOM_UPDATE_MULTI;
+ is_multiupdate= true;
+ }
else if (slex->get_table_list()->derived)
{
/* it is single table update and it is update of derived table */
@@ -13273,10 +13280,13 @@ update:
slex->get_table_list()->alias.str, "UPDATE");
MYSQL_YYABORT;
}
+ if (!(lex->m_sql_cmd=
+ new (thd->mem_root) Sql_cmd_update(is_multiupdate)))
+ MYSQL_YYABORT;
/*
In case of multi-update setting write lock for all tables may
- be too pessimistic. We will decrease lock level if possible in
- mysql_multi_update().
+ be too pessimistic. We will decrease lock level if possible
+ later while processing the statement.
*/
slex->set_lock_for_tables($3, slex->table_list.elements == 1, false);
}
@@ -13333,12 +13343,11 @@ delete:
DELETE_SYM
{
LEX *lex= Lex;
- lex->sql_command= SQLCOM_DELETE;
YYPS->m_lock_type= TL_WRITE_DEFAULT;
YYPS->m_mdl_type= MDL_SHARED_WRITE;
if (Lex->main_select_push())
MYSQL_YYABORT;
- lex->init_select();
+ mysql_init_delete(lex);
lex->ignore= 0;
lex->first_select_lex()->order_list.empty();
}
@@ -13364,11 +13373,17 @@ delete_part2:
opt_delete_options single_multi {}
| HISTORY_SYM delete_single_table opt_delete_system_time
{
- Lex->last_table()->vers_conditions= Lex->vers_conditions;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
+ LEX *lex= Lex;
+ lex->last_table()->vers_conditions= lex->vers_conditions;
+ lex->sql_command= SQLCOM_DELETE;
+ if (!(lex->m_sql_cmd=
+ new (thd->mem_root) Sql_cmd_delete(false)))
+ MYSQL_YYABORT;
+ if (lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
+ stmt_end
+ {}
;
delete_single_table:
@@ -13379,8 +13394,23 @@ delete_single_table:
YYPS->m_lock_type,
YYPS->m_mdl_type,
NULL,
+ 0)))
+ MYSQL_YYABORT;
+ Select->table_list.save_and_clear(&Lex->auxiliary_table_list);
+ /* Save the number of auxiliary tables */
+ Lex->table_count_update= 1;
+
+ Lex->query_tables= 0;
+ Lex->query_tables_last= &Lex->query_tables;
+ if (unlikely(!Select->
+ add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING,
+ YYPS->m_lock_type,
+ YYPS->m_mdl_type,
+ NULL,
$3)))
MYSQL_YYABORT;
+ Lex->auxiliary_table_list.first->correspondent_table=
+ Lex->query_tables;
YYPS->m_lock_type= TL_READ_DEFAULT;
YYPS->m_mdl_type= MDL_SHARED_READ;
}
@@ -13401,14 +13431,24 @@ single_multi:
delete_limit_clause
opt_returning
{
+ LEX *lex= Lex;
if ($3)
Select->order_list= *($3);
- Lex->pop_select(); //main select
+ lex->sql_command= SQLCOM_DELETE;
+ if (!(lex->m_sql_cmd=
+ new (thd->mem_root) Sql_cmd_delete(false)))
+ MYSQL_YYABORT;
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
- | table_wild_list
+ stmt_end {}
+ | table_alias_ref_list
{
+ LEX *lex= Lex;
+ lex->sql_command= SQLCOM_DELETE_MULTI;
+ if (!(lex->m_sql_cmd=
+ new (thd->mem_root) Sql_cmd_delete(true)))
+ MYSQL_YYABORT;
mysql_init_multi_delete(Lex);
YYPS->m_lock_type= TL_READ_DEFAULT;
YYPS->m_mdl_type= MDL_SHARED_READ;
@@ -13420,6 +13460,11 @@ single_multi:
} stmt_end {}
| FROM table_alias_ref_list
{
+ LEX *lex= Lex;
+ lex->sql_command= SQLCOM_DELETE_MULTI;
+ if (!(lex->m_sql_cmd=
+ new (thd->mem_root) Sql_cmd_delete(true)))
+ MYSQL_YYABORT;
mysql_init_multi_delete(Lex);
YYPS->m_lock_type= TL_READ_DEFAULT;
YYPS->m_mdl_type= MDL_SHARED_READ;
@@ -13469,44 +13514,6 @@ opt_returning:
}
;
-table_wild_list:
- table_wild_one
- | table_wild_list ',' table_wild_one
- ;
-
-table_wild_one:
- ident opt_wild
- {
- Table_ident *ti= new (thd->mem_root) Table_ident(&$1);
- if (unlikely(ti == NULL))
- MYSQL_YYABORT;
- if (unlikely(!Select->
- add_table_to_list(thd,
- ti,
- NULL,
- (TL_OPTION_UPDATING |
- TL_OPTION_ALIAS),
- YYPS->m_lock_type,
- YYPS->m_mdl_type)))
- MYSQL_YYABORT;
- }
- | ident '.' ident opt_wild
- {
- Table_ident *ti= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
- if (unlikely(ti == NULL))
- MYSQL_YYABORT;
- if (unlikely(!Select->
- add_table_to_list(thd,
- ti,
- NULL,
- (TL_OPTION_UPDATING |
- TL_OPTION_ALIAS),
- YYPS->m_lock_type,
- YYPS->m_mdl_type)))
- MYSQL_YYABORT;
- }
- ;
-
opt_wild:
/* empty */ {}
| '.' '*' {}
diff --git a/sql/table.cc b/sql/table.cc
index 9ba9817d587..a8eeeb53d72 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -7213,7 +7213,8 @@ void Field_iterator_table_ref::set_field_iterator()
table_ref->alias.str));
}
/* This is a merge view, so use field_translation. */
- else if (table_ref->field_translation)
+ else if (table_ref->field_translation &&
+ !table_ref->is_materialized_derived())
{
DBUG_ASSERT(table_ref->is_merged_derived());
field_it= &view_field_it;
@@ -7223,7 +7224,7 @@ void Field_iterator_table_ref::set_field_iterator()
/* This is a base table or stored view. */
else
{
- DBUG_ASSERT(table_ref->table || table_ref->view);
+ DBUG_ASSERT(table_ref->table || table_ref->is_materialized_derived());
field_it= &table_field_it;
DBUG_PRINT("info", ("field_it for '%s' is Field_iterator_table",
table_ref->alias.str));
@@ -9788,13 +9789,16 @@ bool TABLE_LIST::init_derived(THD *thd, bool init_view)
!derived_table_optimization_done(this))
{
/* A subquery might be forced to be materialized due to a side-effect. */
+ bool forced_no_merge_for_update_delete=
+ belong_to_view ? belong_to_view->updating :
+ !unit->outer_select()->outer_select();
if (!is_materialized_derived() && first_select->is_mergeable() &&
(unit->outer_select() && !unit->outer_select()->with_rownum) &&
(!thd->lex->with_rownum ||
(!first_select->group_list.elements &&
!first_select->order_list.elements)) &&
optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_MERGE) &&
- !thd->lex->can_not_use_merged(1) &&
+ !thd->lex->can_not_use_merged(forced_no_merge_for_update_delete) &&
!is_recursive_with_table())
set_merged_derived();
else
diff --git a/sql/table.h b/sql/table.h
index d9c1231db6a..cad6720570d 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2469,6 +2469,7 @@ struct TABLE_LIST
*/
select_unit *derived_result;
/* Stub used for materialized derived tables. */
+ bool delete_while_scanning;
table_map map; /* ID bit of table (1,2,4,8,16...) */
table_map get_map()
{
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index c69059f8712..ecbfdde1878 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -671,7 +671,7 @@ bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table)
temporary_tables->remove(share);
/* Free the TABLE_SHARE and/or delete the files. */
- free_tmp_table_share(share, delete_table);
+ result= free_tmp_table_share(share, delete_table);
end:
if (locked)
@@ -1464,20 +1464,21 @@ bool THD::log_events_and_free_tmp_shares()
@param share [IN] TABLE_SHARE to free
@param delete_table [IN] Whether to delete the table files?
- @return void
+ @return false Success
+ true Error
*/
-void THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table)
+bool THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table)
{
+ bool error= false;
DBUG_ENTER("THD::free_tmp_table_share");
if (delete_table)
{
- rm_temporary_table(share->db_type(), share->path.str);
+ error= rm_temporary_table(share->db_type(), share->path.str);
}
free_table_share(share);
my_free(share);
-
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
diff --git a/storage/connect/mysql-test/connect/r/upd.result b/storage/connect/mysql-test/connect/r/upd.result
index 8faf00896bb..ad17f0f26ce 100644
--- a/storage/connect/mysql-test/connect/r/upd.result
+++ b/storage/connect/mysql-test/connect/r/upd.result
@@ -1627,3 +1627,159 @@ serialno name sex title manager department secretary salary
DROP PROCEDURE test.tst_up;
DROP TABLE employee;
SET sql_mode = DEFAULT;
+#
+# End of 10.10 tests
+#
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+CREATE TABLE t1
+(
+name char(12) not null,
+city char(11) not null,
+birth date not null date_format='DD/MM/YYYY',
+hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
+CREATE TABLE t2 (
+_id INT(2) NOT NULL,
+name_first CHAR(9) NOT NULL JPATH='$.name.first',
+name_aka CHAR(4) DEFAULT NULL JPATH='$.name.aka',
+name_last CHAR(10) NOT NULL JPATH='$.name.last',
+title CHAR(12) DEFAULT NULL,
+birth CHAR(20) DEFAULT NULL,
+death CHAR(20) DEFAULT NULL,
+contribs CHAR(50) NOT NULL JPATH='$.contribs',
+awards_award CHAR(42) DEFAULT NULL JPATH='$.awards.award',
+awards_year CHAR(4) DEFAULT NULL JPATH='$.awards.year',
+awards_by CHAR(38) DEFAULT NULL JPATH='$.awards.by'
+) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.json';
+# Multi-update
+select t1.name, t1.city from t1;
+name city
+John Boston
+Henry Boston
+George San Jose
+Sam Chicago
+James Dallas
+Bill Boston
+select t2._id, t2.name_first, t2.name_aka, t2.name_last from t2;
+_id name_first name_aka name_last
+1 John NULL Backus
+2 John NULL McCarthy
+3 Grace NULL Hopper
+4 Kristen NULL Nygaard
+5 Ole-Johan NULL Dahl
+6 Guido NULL van Rossum
+7 Dennis NULL Ritchie
+8 Yukihiro Matz Matsumoto
+9 James NULL Gosling
+10 Martin NULL Odersky
+select t1.name, t2.name_last, t2.name_aka, t1.city from t1, t2 where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+name name_last name_aka city
+James Gosling NULL Dallas
+explain update t1, t2
+set t1.city='Washington', t2.name_aka='von' where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
+update t1, t2
+set t1.city='Washington', t2.name_aka='von' where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+select t1.name, t2.name_last, t2.name_aka, t1.city from t1, t2 where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+name name_last name_aka city
+James Gosling von Washington
+# Conversion to multi-update
+select t1.name, t1.city from t1;
+name city
+John Boston
+Henry Boston
+George San Jose
+Sam Chicago
+James Washington
+Bill Boston
+explain update t1
+set t1.city='New York' where t1.name in (select t2.name_first from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 6
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; FirstMatch(t1)
+update t1
+set t1.city='New York' where t1.name in (select t2.name_first from t2);
+select t1.name, t1.city from t1;
+name city
+John New York
+Henry Boston
+George San Jose
+Sam Chicago
+James New York
+Bill Boston
+select t1.name, t1.city from t1 where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+name city
+George San Jose
+explain update t1 set t1.city='Los Angeles' where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 6
+1 PRIMARY a ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1)
+update t1 set t1.city='Los Angeles' where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+select t1.name, t1.city from t1 where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+name city
+George Los Angeles
+# Multi-delete
+explain delete t1.*, t2.* from t1, t2 where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
+delete t1.*, t2.* from t1, t2 where t1.name=t2.name_first and t1.birth
+BETWEEN '1992-01-01' and '1995-01-01';
+select t1.name, t1.city from t1;
+name city
+John New York
+Henry Boston
+George Los Angeles
+Sam Chicago
+Bill Boston
+select t2._id, t2.name_first, t2.name_aka, t2.name_last from t2;
+_id name_first name_aka name_last
+1 John NULL Backus
+2 John NULL McCarthy
+3 Grace NULL Hopper
+4 Kristen NULL Nygaard
+5 Ole-Johan NULL Dahl
+6 Guido NULL van Rossum
+7 Dennis NULL Ritchie
+8 Yukihiro Matz Matsumoto
+10 Martin NULL Odersky
+# Conversion to multi-delete
+explain delete from t1 where t1.name in (select t2.name_first from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where; FirstMatch(t1)
+delete from t1 where t1.name in (select t2.name_first from t2);
+select t1.name, t1.city from t1;
+name city
+Henry Boston
+George Los Angeles
+Sam Chicago
+Bill Boston
+explain delete from t1 where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4
+1 PRIMARY a ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1)
+delete from t1 where t1.name in (select a.name from t1 as a where a.birth
+BETWEEN '1981-01-01' and '1982-01-01');
+select t1.name, t1.city from t1;
+name city
+Henry Boston
+Sam Chicago
+Bill Boston
+drop tables t1, t2;
+SET sql_mode = DEFAULT;
+#
+# End of 11.0 tests
+#
diff --git a/storage/connect/mysql-test/connect/t/upd.test b/storage/connect/mysql-test/connect/t/upd.test
index 28b566b5641..0372a9a83a1 100644
--- a/storage/connect/mysql-test/connect/t/upd.test
+++ b/storage/connect/mysql-test/connect/t/upd.test
@@ -155,3 +155,99 @@ DROP TABLE employee;
SET sql_mode = DEFAULT;
--remove_file $MYSQLD_DATADIR/test/employee.dat
+
+--echo #
+--echo # End of 10.10 tests
+--echo #
+
+--copy_file $MTR_SUITE_DIR/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt
+--copy_file $MTR_SUITE_DIR/std_data/bios.json $MYSQLD_DATADIR/test/bios.json
+
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+
+CREATE TABLE t1
+(
+ name char(12) not null,
+ city char(11) not null,
+ birth date not null date_format='DD/MM/YYYY',
+ hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
+
+CREATE TABLE t2 (
+ _id INT(2) NOT NULL,
+ name_first CHAR(9) NOT NULL JPATH='$.name.first',
+ name_aka CHAR(4) DEFAULT NULL JPATH='$.name.aka',
+ name_last CHAR(10) NOT NULL JPATH='$.name.last',
+ title CHAR(12) DEFAULT NULL,
+ birth CHAR(20) DEFAULT NULL,
+ death CHAR(20) DEFAULT NULL,
+ contribs CHAR(50) NOT NULL JPATH='$.contribs',
+ awards_award CHAR(42) DEFAULT NULL JPATH='$.awards.award',
+ awards_year CHAR(4) DEFAULT NULL JPATH='$.awards.year',
+ awards_by CHAR(38) DEFAULT NULL JPATH='$.awards.by'
+) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.json';
+
+--echo # Multi-update
+
+select t1.name, t1.city from t1;
+select t2._id, t2.name_first, t2.name_aka, t2.name_last from t2;
+
+let $c1 = where t1.name=t2.name_first and t1.birth
+ BETWEEN '1992-01-01' and '1995-01-01';
+
+eval select t1.name, t2.name_last, t2.name_aka, t1.city from t1, t2 $c1;
+eval explain update t1, t2
+ set t1.city='Washington', t2.name_aka='von' $c1;
+eval update t1, t2
+ set t1.city='Washington', t2.name_aka='von' $c1;
+eval select t1.name, t2.name_last, t2.name_aka, t1.city from t1, t2 $c1;
+
+--echo # Conversion to multi-update
+
+let $c2 = where t1.name in (select t2.name_first from t2);
+
+select t1.name, t1.city from t1;
+eval explain update t1
+ set t1.city='New York' $c2;
+eval update t1
+ set t1.city='New York' $c2;
+select t1.name, t1.city from t1;
+
+let $c3 = where t1.name in (select a.name from t1 as a where a.birth
+ BETWEEN '1981-01-01' and '1982-01-01');
+
+eval select t1.name, t1.city from t1 $c3;
+eval explain update t1 set t1.city='Los Angeles' $c3;
+eval update t1 set t1.city='Los Angeles' $c3;
+eval select t1.name, t1.city from t1 $c3;
+
+--echo # Multi-delete
+
+eval explain delete t1.*, t2.* from t1, t2 $c1;
+eval delete t1.*, t2.* from t1, t2 $c1;
+
+select t1.name, t1.city from t1;
+select t2._id, t2.name_first, t2.name_aka, t2.name_last from t2;
+
+--echo # Conversion to multi-delete
+
+eval explain delete from t1 $c2;
+eval delete from t1 $c2;
+
+select t1.name, t1.city from t1;
+
+eval explain delete from t1 $c3;
+eval delete from t1 $c3;
+
+select t1.name, t1.city from t1;
+
+drop tables t1, t2;
+
+SET sql_mode = DEFAULT;
+
+--remove_file $MYSQLD_DATADIR/test/boys.txt
+--remove_file $MYSQLD_DATADIR/test/bios.json
+
+--echo #
+--echo # End of 11.0 tests
+--echo #
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index d4471076780..dddff5e22b8 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -250,7 +250,7 @@ Gets the root node of a tree and x- or s-latches it.
buf_block_t*
btr_root_block_get(
/*===============*/
- const dict_index_t* index, /*!< in: index tree */
+ dict_index_t* index, /*!< in: index tree */
rw_lock_type_t mode, /*!< in: either RW_S_LATCH
or RW_X_LATCH */
mtr_t* mtr, /*!< in: mtr */
@@ -262,18 +262,42 @@ btr_root_block_get(
return nullptr;
}
- buf_block_t *block = btr_block_get(*index, index->page, mode, mtr, err);
- if (block)
+ buf_block_t *block;
+#ifndef BTR_CUR_ADAPT
+ static constexpr buf_block_t *guess= nullptr;
+#else
+ buf_block_t *&guess= btr_search_get_info(index)->root_guess;
+ guess=
+#endif
+ block=
+ buf_page_get_gen(page_id_t{index->table->space->id, index->page},
+ index->table->space->zip_size(), mode, guess, BUF_GET,
+ mtr, err);
+ ut_ad(!block == (*err != DB_SUCCESS));
+
+ if (UNIV_LIKELY(block != nullptr))
{
- if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF,
- *block, *index->table->space) ||
- !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP,
- *block, *index->table->space))
+ if (!!page_is_comp(block->page.frame) != index->table->not_redundant() ||
+ btr_page_get_index_id(block->page.frame) != index->id ||
+ !fil_page_index_page_check(block->page.frame) ||
+ index->is_spatial() !=
+ (fil_page_get_type(block->page.frame) == FIL_PAGE_RTREE))
+ {
+ *err= DB_PAGE_CORRUPTED;
+ block= nullptr;
+ }
+ else if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF,
+ *block, *index->table->space) ||
+ !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP,
+ *block, *index->table->space))
{
*err= DB_CORRUPTION;
block= nullptr;
}
}
+ else if (*err == DB_DECRYPTION_FAILED)
+ btr_decryption_failed(*index);
+
return block;
}
@@ -284,7 +308,7 @@ static
page_t*
btr_root_get(
/*=========*/
- const dict_index_t* index, /*!< in: index tree */
+ dict_index_t* index, /*!< in: index tree */
mtr_t* mtr, /*!< in: mtr */
dberr_t* err) /*!< out: error code */
{
@@ -496,9 +520,7 @@ btr_block_reget(mtr_t *mtr, const dict_index_t &index,
return block;
}
-#if 0 /* MDEV-29385 FIXME: Acquire the page latch upfront. */
ut_ad(mtr->memo_contains_flagged(&index.lock, MTR_MEMO_X_LOCK));
-#endif
return btr_block_get(index, id.page_no(), rw_latch, mtr, err);
}
@@ -686,9 +708,7 @@ btr_page_get_father_node_ptr_for_validate(
const uint32_t page_no = btr_cur_get_block(cursor)->page.id().page_no();
dict_index_t* index = btr_cur_get_index(cursor);
ut_ad(!dict_index_is_spatial(index));
-
- ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
- | MTR_MEMO_SX_LOCK));
+ ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_X_LOCK));
ut_ad(dict_index_get_page(index) != page_no);
const auto level = btr_page_get_level(btr_cur_get_page(cursor));
@@ -706,10 +726,6 @@ btr_page_get_father_node_ptr_for_validate(
}
const rec_t* node_ptr = btr_cur_get_rec(cursor);
-#if 0 /* MDEV-29835 FIXME */
- ut_ad(!btr_cur_get_block(cursor)->page.lock.not_recursive()
- || mtr->memo_contains(index->lock, MTR_MEMO_X_LOCK));
-#endif
offsets = rec_get_offsets(node_ptr, index, offsets, 0,
ULINT_UNDEFINED, &heap);
@@ -2287,11 +2303,10 @@ btr_insert_on_non_leaf_level(
}
ut_ad(cursor.flag == BTR_CUR_BINARY);
-#if 0 /* MDEV-29835 FIXME */
- ut_ad(!btr_cur_get_block(&cursor)->page.lock.not_recursive()
+ ut_ad(btr_cur_get_block(&cursor)
+ != mtr->at_savepoint(mtr->get_savepoint() - 1)
|| index->is_spatial()
|| mtr->memo_contains(index->lock, MTR_MEMO_X_LOCK));
-#endif
if (UNIV_LIKELY(err == DB_SUCCESS)) {
err = btr_cur_optimistic_insert(flags,
@@ -2399,10 +2414,8 @@ btr_attach_half_pages(
prev_block = mtr->get_already_latched(id, MTR_MEMO_PAGE_X_FIX);
#if 1 /* MDEV-29835 FIXME: acquire page latches upfront */
if (!prev_block) {
-# if 0 /* MDEV-29835 FIXME */
ut_ad(mtr->memo_contains(index->lock,
MTR_MEMO_X_LOCK));
-# endif
prev_block = btr_block_get(*index, prev_page_no,
RW_X_LATCH, mtr);
}
@@ -2413,10 +2426,8 @@ btr_attach_half_pages(
next_block = mtr->get_already_latched(id, MTR_MEMO_PAGE_X_FIX);
#if 1 /* MDEV-29835 FIXME: acquire page latches upfront */
if (!next_block) {
-# if 0 /* MDEV-29835 FIXME */
ut_ad(mtr->memo_contains(index->lock,
MTR_MEMO_X_LOCK));
-# endif
next_block = btr_block_get(*index, next_page_no,
RW_X_LATCH, mtr);
}
@@ -2757,6 +2768,8 @@ btr_page_split_and_insert(
ut_ad(dtuple_check_typed(tuple));
ut_ad(!cursor->index()->is_spatial());
+ buf_pool.pages_split++;
+
if (!*heap) {
*heap = mem_heap_create(1024);
}
@@ -3124,8 +3137,6 @@ insert_failed:
}
func_exit:
- MONITOR_INC(MONITOR_INDEX_SPLIT);
-
ut_ad(page_validate(buf_block_get_frame(left_block),
page_cursor->index));
ut_ad(page_validate(buf_block_get_frame(right_block),
@@ -3160,9 +3171,7 @@ dberr_t btr_level_list_remove(const buf_block_t& block,
#if 1 /* MDEV-29835 FIXME: acquire page latches upfront */
if (!prev)
{
-# if 0 /* MDEV-29835 FIXME */
ut_ad(mtr->memo_contains(index.lock, MTR_MEMO_X_LOCK));
-# endif
prev= btr_block_get(index, id.page_no(), RW_X_LATCH, mtr, &err);
if (UNIV_UNLIKELY(!prev))
return err;
@@ -3177,9 +3186,7 @@ dberr_t btr_level_list_remove(const buf_block_t& block,
#if 1 /* MDEV-29835 FIXME: acquire page latches upfront */
if (!next)
{
-# if 0 /* MDEV-29835 FIXME */
ut_ad(mtr->memo_contains(index.lock, MTR_MEMO_X_LOCK));
-# endif
next= btr_block_get(index, id.page_no(), RW_X_LATCH, mtr, &err);
if (UNIV_UNLIKELY(!next))
return err;
@@ -4009,7 +4016,7 @@ btr_discard_page(
if (UNIV_UNLIKELY(!merge_block)) {
return err;
}
-#if 0 /* MDEV-29385 FIXME: Acquire the page latch upfront. */
+#if 1 /* MDEV-29835 FIXME: Acquire the page latch upfront. */
ut_ad(!memcmp_aligned<4>(merge_block->page.frame
+ FIL_PAGE_NEXT,
block->page.frame + FIL_PAGE_OFFSET,
@@ -4035,7 +4042,7 @@ btr_discard_page(
if (UNIV_UNLIKELY(!merge_block)) {
return err;
}
-#if 0 /* MDEV-29385 FIXME: Acquire the page latch upfront. */
+#if 1 /* MDEV-29835 FIXME: Acquire the page latch upfront. */
ut_ad(!memcmp_aligned<4>(merge_block->page.frame
+ FIL_PAGE_PREV,
block->page.frame + FIL_PAGE_OFFSET,
@@ -4606,8 +4613,7 @@ btr_validate_level(
/*===============*/
dict_index_t* index, /*!< in: index tree */
const trx_t* trx, /*!< in: transaction or NULL */
- ulint level, /*!< in: level number */
- bool lockout)/*!< in: true if X-latch index is intended */
+ ulint level) /*!< in: level number */
{
buf_block_t* block;
page_t* page;
@@ -4626,18 +4632,10 @@ btr_validate_level(
#ifdef UNIV_ZIP_DEBUG
page_zip_des_t* page_zip;
#endif /* UNIV_ZIP_DEBUG */
- ulint savepoint = 0;
- uint32_t parent_page_no = FIL_NULL;
- uint32_t parent_right_page_no = FIL_NULL;
- bool rightmost_child = false;
mtr.start();
- if (lockout) {
- mtr_x_lock_index(index, &mtr);
- } else {
- mtr_sx_lock_index(index, &mtr);
- }
+ mtr_x_lock_index(index, &mtr);
dberr_t err;
block = btr_root_block_get(index, RW_SX_LATCH, &mtr, &err);
@@ -4732,11 +4730,7 @@ func_exit:
mem_heap_empty(heap);
offsets = offsets2 = NULL;
- if (lockout) {
- mtr_x_lock_index(index, &mtr);
- } else {
- mtr_sx_lock_index(index, &mtr);
- }
+ mtr_x_lock_index(index, &mtr);
page = block->page.frame;
@@ -4780,7 +4774,6 @@ func_exit:
if (right_page_no != FIL_NULL) {
const rec_t* right_rec;
- savepoint = mtr.get_savepoint();
right_block = btr_block_get(*index, right_page_no, RW_SX_LATCH,
&mtr, &err);
@@ -4883,11 +4876,6 @@ broken_links:
father_page = btr_cur_get_page(&node_cur);
node_ptr = btr_cur_get_rec(&node_cur);
- parent_page_no = page_get_page_no(father_page);
- parent_right_page_no = btr_page_get_next(father_page);
- rightmost_child = page_rec_is_supremum(
- page_rec_get_next(node_ptr));
-
rec = page_rec_get_prev(page_get_supremum_rec(page));
if (rec) {
btr_cur_position(index, rec, block, &node_cur);
@@ -4969,35 +4957,6 @@ broken_links:
}
} else if (const rec_t* right_node_ptr
= page_rec_get_next(node_ptr)) {
- if (!lockout && rightmost_child) {
-
- /* To obey latch order of tree blocks,
- we should release the right_block once to
- obtain lock of the uncle block. */
- ut_ad(right_block
- == mtr.at_savepoint(savepoint));
- mtr.rollback_to_savepoint(savepoint,
- savepoint + 1);
-
- if (parent_right_page_no != FIL_NULL) {
- btr_block_get(*index,
- parent_right_page_no,
- RW_SX_LATCH, &mtr);
- }
-
- right_block = btr_block_get(*index,
- right_page_no,
- RW_SX_LATCH,
- &mtr, &err);
- if (!right_block) {
- btr_validate_report1(index, level,
- block);
- fputs("InnoDB: broken FIL_PAGE_NEXT"
- " link\n", stderr);
- goto invalid_page;
- }
- }
-
btr_cur_position(
index,
page_get_infimum_rec(right_block->page.frame),
@@ -5069,19 +5028,6 @@ node_ptr_fails:
mtr.start();
- if (!lockout) {
- if (rightmost_child) {
- if (parent_right_page_no != FIL_NULL) {
- btr_block_get(*index,
- parent_right_page_no,
- RW_SX_LATCH, &mtr);
- }
- } else if (parent_page_no != FIL_NULL) {
- btr_block_get(*index, parent_page_no,
- RW_SX_LATCH, &mtr);
- }
- }
-
block = btr_block_get(*index, right_page_no, RW_SX_LATCH,
&mtr, &err);
goto loop;
@@ -5099,21 +5045,16 @@ btr_validate_index(
dict_index_t* index, /*!< in: index */
const trx_t* trx) /*!< in: transaction or NULL */
{
- const bool lockout= index->is_spatial();
-
mtr_t mtr;
mtr.start();
- if (lockout)
- mtr_x_lock_index(index, &mtr);
- else
- mtr_sx_lock_index(index, &mtr);
+ mtr_x_lock_index(index, &mtr);
dberr_t err;
if (page_t *root= btr_root_get(index, &mtr, &err))
for (auto level= btr_page_get_level(root);; level--)
{
- if (dberr_t err_level= btr_validate_level(index, trx, level, lockout))
+ if (dberr_t err_level= btr_validate_level(index, trx, level))
err= err_level;
if (!level)
break;
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 2941a765fa4..74db3fa3d8f 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -750,29 +750,34 @@ btr_cur_will_modify_tree(
/** Detects whether the modifying record might need a opposite modification
to the intention.
-@param[in] page page
-@param[in] lock_intention lock intention for the tree operation
-@param[in] rec record (current node_ptr)
+@param page page
+@param lock_intention lock intention for the tree operation
+@param node_ptr_max_size the maximum size of a node pointer
+@param compress_limit BTR_CUR_PAGE_COMPRESS_LIMIT(index)
+@param rec record (current node_ptr)
@return true if tree modification is needed */
-static
-bool
-btr_cur_need_opposite_intention(
- const page_t* page,
- btr_intention_t lock_intention,
- const rec_t* rec)
+static bool btr_cur_need_opposite_intention(const page_t *page,
+ btr_intention_t lock_intention,
+ ulint node_ptr_max_size,
+ ulint compress_limit,
+ const rec_t *rec)
{
- switch (lock_intention) {
- case BTR_INTENTION_DELETE:
- return (page_has_prev(page) && page_rec_is_first(rec, page)) ||
- (page_has_next(page) && page_rec_is_last(rec, page));
- case BTR_INTENTION_INSERT:
- return page_has_next(page) && page_rec_is_last(rec, page);
- case BTR_INTENTION_BOTH:
- return(false);
- }
-
- MY_ASSERT_UNREACHABLE();
- return(false);
+ if (lock_intention != BTR_INTENTION_INSERT)
+ {
+ /* We compensate also for btr_cur_compress_recommendation() */
+ if (!page_has_siblings(page) ||
+ page_rec_is_first(rec, page) || page_rec_is_last(rec, page) ||
+ page_get_data_size(page) < node_ptr_max_size + compress_limit)
+ return true;
+ if (lock_intention == BTR_INTENTION_DELETE)
+ return false;
+ }
+ else if (page_has_next(page) && page_rec_is_last(rec, page))
+ return true;
+ LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page), return true);
+ const ulint max_size= page_get_max_insert_size_after_reorganize(page, 2);
+ return max_size < BTR_CUR_PAGE_REORGANIZE_LIMIT + node_ptr_max_size ||
+ max_size < node_ptr_max_size * 2;
}
/**
@@ -997,7 +1002,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
const ulint savepoint= mtr->get_savepoint();
- ulint node_ptr_max_size= 0;
+ ulint node_ptr_max_size= 0, compress_limit= 0;
rw_lock_type_t rw_latch= RW_S_LATCH;
switch (latch_mode) {
@@ -1009,13 +1014,19 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
ut_ad(mtr->memo_contains_flagged(&index()->lock, MTR_MEMO_X_LOCK));
break;
}
- if (lock_intention == BTR_INTENTION_DELETE && buf_pool.n_pend_reads &&
- trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
- /* Most delete-intended operations are due to the purge of history.
- Prioritize them when the history list is growing huge. */
- mtr_x_lock_index(index(), mtr);
- else
- mtr_sx_lock_index(index(), mtr);
+ if (lock_intention == BTR_INTENTION_DELETE)
+ {
+ compress_limit= BTR_CUR_PAGE_COMPRESS_LIMIT(index());
+ if (buf_pool.n_pend_reads &&
+ trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
+ {
+ /* Most delete-intended operations are due to the purge of history.
+ Prioritize them when the history list is growing huge. */
+ mtr_x_lock_index(index(), mtr);
+ break;
+ }
+ }
+ mtr_sx_lock_index(index(), mtr);
break;
#ifdef UNIV_DEBUG
case BTR_CONT_MODIFY_TREE:
@@ -1221,6 +1232,10 @@ release_tree:
!btr_block_get(*index(), btr_page_get_next(block->page.frame),
RW_X_LATCH, mtr, &err))
goto func_exit;
+ if (btr_cur_need_opposite_intention(block->page.frame, lock_intention,
+ node_ptr_max_size, compress_limit,
+ page_cur.rec))
+ goto need_opposite_intention;
}
reached_latched_leaf:
@@ -1274,6 +1289,7 @@ release_tree:
break;
case BTR_MODIFY_TREE:
if (btr_cur_need_opposite_intention(block->page.frame, lock_intention,
+ node_ptr_max_size, compress_limit,
page_cur.rec))
/* If the rec is the first or last in the page for pessimistic
delete intention, it might cause node_ptr insert for the upper
@@ -1417,6 +1433,17 @@ release_tree:
goto search_loop;
}
+ATTRIBUTE_COLD void mtr_t::index_lock_upgrade()
+{
+ auto &slot= m_memo[get_savepoint() - 1];
+ if (slot.type == MTR_MEMO_X_LOCK)
+ return;
+ ut_ad(slot.type == MTR_MEMO_SX_LOCK);
+ index_lock *lock= static_cast<index_lock*>(slot.object);
+ lock->u_x_upgrade(SRW_LOCK_CALL);
+ slot.type= MTR_MEMO_X_LOCK;
+}
+
ATTRIBUTE_COLD
dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple,
page_cur_mode_t mode, mtr_t *mtr)
@@ -1434,8 +1461,7 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple,
ut_ad(block->page.id().page_no() == index()->page);
block->page.fix();
mtr->rollback_to_savepoint(1);
- ut_ad(mtr->memo_contains_flagged(&index()->lock,
- MTR_MEMO_SX_LOCK | MTR_MEMO_X_LOCK));
+ mtr->index_lock_upgrade();
const page_cur_mode_t page_mode{btr_cur_nonleaf_mode(mode)};
@@ -1665,7 +1691,6 @@ search_loop:
dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
btr_latch_mode latch_mode, mtr_t *mtr)
{
- btr_intention_t lock_intention;
ulint n_blocks= 0;
mem_heap_t *heap= nullptr;
rec_offs offsets_[REC_OFFS_NORMAL_SIZE];
@@ -1677,7 +1702,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
const bool latch_by_caller= latch_mode & BTR_ALREADY_S_LATCHED;
latch_mode= btr_latch_mode(latch_mode & ~BTR_ALREADY_S_LATCHED);
- lock_intention= btr_cur_get_and_clear_intention(&latch_mode);
+ btr_intention_t lock_intention= btr_cur_get_and_clear_intention(&latch_mode);
/* Store the position of the tree latch we push to mtr so that we
know how to release it when we have latched the leaf node */
@@ -1685,7 +1710,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
auto savepoint= mtr->get_savepoint();
rw_lock_type_t upper_rw_latch= RW_X_LATCH;
- ulint node_ptr_max_size= 0;
+ ulint node_ptr_max_size= 0, compress_limit= 0;
if (latch_mode == BTR_MODIFY_TREE)
{
@@ -1694,12 +1719,18 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
and read IO bandwidth should be prioritized for them, when the
history list is growing huge. */
savepoint++;
- if (lock_intention == BTR_INTENTION_DELETE
- && buf_pool.n_pend_reads
- && trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
- mtr_x_lock_index(index, mtr);
- else
- mtr_sx_lock_index(index, mtr);
+ if (lock_intention == BTR_INTENTION_DELETE)
+ {
+ compress_limit= BTR_CUR_PAGE_COMPRESS_LIMIT(index);
+
+ if (buf_pool.n_pend_reads &&
+ trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
+ {
+ mtr_x_lock_index(index, mtr);
+ goto index_locked;
+ }
+ }
+ mtr_sx_lock_index(index, mtr);
}
else
{
@@ -1720,6 +1751,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
}
}
+index_locked:
ut_ad(savepoint == mtr->get_savepoint());
const rw_lock_type_t root_leaf_rw_latch=
@@ -1792,15 +1824,28 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
!btr_block_get(*index, btr_page_get_next(block->page.frame),
RW_X_LATCH, mtr, &err))
break;
+
+ if (!index->lock.have_x() &&
+ btr_cur_need_opposite_intention(block->page.frame,
+ lock_intention,
+ node_ptr_max_size,
+ compress_limit, page_cur.rec))
+ goto need_opposite_intention;
}
else
{
if (rw_latch == RW_NO_LATCH)
mtr->upgrade_buffer_fix(leaf_savepoint - 1,
- rw_lock_type_t(latch_mode));
- /* Release index->lock if needed, and the non-leaf pages. */
- mtr->rollback_to_savepoint(savepoint - !latch_by_caller,
- leaf_savepoint - 1);
+ rw_lock_type_t(latch_mode &
+ (RW_X_LATCH | RW_S_LATCH)));
+ if (latch_mode != BTR_CONT_MODIFY_TREE)
+ {
+ ut_ad(latch_mode == BTR_MODIFY_LEAF ||
+ latch_mode == BTR_SEARCH_LEAF);
+ /* Release index->lock if needed, and the non-leaf pages. */
+ mtr->rollback_to_savepoint(savepoint - !latch_by_caller,
+ leaf_savepoint - 1);
+ }
}
break;
}
@@ -1822,22 +1867,25 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
: !page_cur_move_to_prev(&page_cur))
goto corrupted;
- const rec_t *node_ptr= page_cur.rec;
- offsets= rec_get_offsets(node_ptr, index, offsets, 0, ULINT_UNDEFINED,
+ offsets= rec_get_offsets(page_cur.rec, index, offsets, 0, ULINT_UNDEFINED,
&heap);
ut_ad(latch_mode != BTR_MODIFY_TREE || upper_rw_latch == RW_X_LATCH);
if (latch_mode != BTR_MODIFY_TREE);
- else if (btr_cur_need_opposite_intention(block->page.frame,
- lock_intention, node_ptr))
+ else if (btr_cur_need_opposite_intention(block->page.frame, lock_intention,
+ node_ptr_max_size, compress_limit,
+ page_cur.rec))
{
+ need_opposite_intention:
/* If the rec is the first or last in the page for pessimistic
delete intention, it might cause node_ptr insert for the upper
level. We should change the intention and retry. */
mtr->rollback_to_savepoint(savepoint);
- lock_intention= BTR_INTENTION_BOTH;
+ mtr->index_lock_upgrade();
+ /* X-latch all pages from now on */
+ latch_mode= BTR_CONT_MODIFY_TREE;
page= index->page;
height= ULINT_UNDEFINED;
n_blocks= 0;
@@ -1846,7 +1894,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
else
{
if (!btr_cur_will_modify_tree(index, block->page.frame,
- lock_intention, node_ptr,
+ lock_intention, page_cur.rec,
node_ptr_max_size, zip_size, mtr))
{
ut_ad(n_blocks);
@@ -1876,7 +1924,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
}
/* Go to the child node */
- page= btr_node_ptr_get_child_page_no(node_ptr, offsets);
+ page= btr_node_ptr_get_child_page_no(page_cur.rec, offsets);
n_blocks++;
}
@@ -2178,8 +2226,7 @@ convert_big_rec:
return(DB_TOO_BIG_RECORD);
}
- LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page),
- goto fail);
+ LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page), goto fail);
if (block->page.zip.data && leaf
&& (page_get_data_size(page) + rec_size
@@ -2193,7 +2240,7 @@ fail:
/* prefetch siblings of the leaf for the pessimistic
operation, if the page is leaf. */
- if (page_is_leaf(page)) {
+ if (leaf) {
btr_cur_prefetch_siblings(block, index);
}
fail_err:
@@ -2262,7 +2309,7 @@ fail_err:
#ifdef UNIV_DEBUG
if (!(flags & BTR_CREATE_FLAG)
- && index->is_primary() && page_is_leaf(page)) {
+ && leaf && index->is_primary()) {
const dfield_t* trx_id = dtuple_get_nth_field(
entry, dict_col_get_clust_pos(
dict_table_get_sys_col(index->table,
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 0a4da87083a..4de8b4fd175 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -408,7 +408,6 @@ static bool buf_page_decrypt_after_read(buf_page_t *bpage,
if (id.space() == SRV_TMP_SPACE_ID
&& innodb_encrypt_temporary_tables) {
slot = buf_pool.io_buf_reserve();
- ut_a(slot);
slot->allocate();
bool ok = buf_tmp_page_decrypt(slot->crypt_buf, dst_frame);
slot->release();
@@ -431,7 +430,6 @@ decompress:
}
slot = buf_pool.io_buf_reserve();
- ut_a(slot);
slot->allocate();
decompress_with_slot:
@@ -455,7 +453,6 @@ decrypt_failed:
}
slot = buf_pool.io_buf_reserve();
- ut_a(slot);
slot->allocate();
/* decrypt using crypt_buf to dst_frame */
@@ -1287,6 +1284,41 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
return(true); /* free_list was enough */
}
+void buf_pool_t::io_buf_t::create(ulint n_slots)
+{
+ this->n_slots= n_slots;
+ slots= static_cast<buf_tmp_buffer_t*>
+ (ut_malloc_nokey(n_slots * sizeof *slots));
+ memset((void*) slots, 0, n_slots * sizeof *slots);
+}
+
+void buf_pool_t::io_buf_t::close()
+{
+ for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
+ {
+ aligned_free(s->crypt_buf);
+ aligned_free(s->comp_buf);
+ }
+ ut_free(slots);
+ slots= nullptr;
+ n_slots= 0;
+}
+
+buf_tmp_buffer_t *buf_pool_t::io_buf_t::reserve()
+{
+ for (;;)
+ {
+ for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
+ if (s->acquire())
+ return s;
+ os_aio_wait_until_no_pending_writes();
+ for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
+ if (s->acquire())
+ return s;
+ os_aio_wait_until_no_pending_reads();
+ }
+}
+
/** Sets the global variable that feeds MySQL's innodb_buffer_pool_resize_status
to the specified string. The format and the following parameters are the
same as the ones used for printf(3).
@@ -1353,21 +1385,25 @@ inline bool buf_pool_t::withdraw_blocks()
block = next_block;
}
- mysql_mutex_unlock(&mutex);
/* reserve free_list length */
if (UT_LIST_GET_LEN(withdraw) < withdraw_target) {
buf_flush_LRU(
std::max<ulint>(withdraw_target
- UT_LIST_GET_LEN(withdraw),
- srv_LRU_scan_depth));
- buf_flush_wait_batch_end_acquiring_mutex(true);
+ srv_LRU_scan_depth),
+ true);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ buf_dblwr.flush_buffered_writes();
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_flush_wait_LRU_batch_end();
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
}
/* relocate blocks/buddies in withdrawn area */
ulint count2 = 0;
- mysql_mutex_lock(&mutex);
buf_pool_mutex_exit_forbid();
for (buf_page_t* bpage = UT_LIST_GET_FIRST(LRU), *next_bpage;
bpage; bpage = next_bpage) {
@@ -2095,13 +2131,15 @@ lookup:
return bpage;
must_read_page:
- if (dberr_t err= buf_read_page(page_id, zip_size, chain))
- {
+ switch (dberr_t err= buf_read_page(page_id, zip_size, chain)) {
+ case DB_SUCCESS:
+ case DB_SUCCESS_LOCKED_REC:
+ goto lookup;
+ default:
ib::error() << "Reading compressed page " << page_id
<< " failed with error: " << err;
return nullptr;
}
- goto lookup;
}
/********************************************************************//**
@@ -2245,15 +2283,14 @@ buf_page_get_low(
#ifdef UNIV_DEBUG
switch (mode) {
- case BUF_PEEK_IF_IN_POOL:
+ default:
+ ut_ad(mode == BUF_PEEK_IF_IN_POOL);
+ break;
+ case BUF_GET_POSSIBLY_FREED:
case BUF_GET_IF_IN_POOL:
/* The caller may pass a dummy page size,
because it does not really matter. */
break;
- default:
- MY_ASSERT_UNREACHABLE();
- case BUF_GET_POSSIBLY_FREED:
- break;
case BUF_GET:
ut_ad(!mtr->is_freeing_tree());
fil_space_t* s = fil_space_get(page_id.space());
@@ -2319,20 +2356,23 @@ loop:
corrupted, or if an encrypted page with a valid
checksum cannot be decypted. */
- if (dberr_t local_err = buf_read_page(page_id, zip_size, chain)) {
- if (local_err != DB_CORRUPTION
- && mode != BUF_GET_POSSIBLY_FREED
+ switch (dberr_t local_err = buf_read_page(page_id, zip_size, chain)) {
+ case DB_SUCCESS:
+ case DB_SUCCESS_LOCKED_REC:
+ buf_read_ahead_random(page_id, zip_size);
+ break;
+ default:
+ if (mode != BUF_GET_POSSIBLY_FREED
&& retries++ < BUF_PAGE_READ_MAX_RETRIES) {
DBUG_EXECUTE_IF("intermittent_read_failure",
retries = BUF_PAGE_READ_MAX_RETRIES;);
- } else {
- if (err) {
- *err = local_err;
- }
- return nullptr;
}
- } else {
- buf_read_ahead_random(page_id, zip_size);
+ /* fall through */
+ case DB_PAGE_CORRUPTED:
+ if (err) {
+ *err = local_err;
+ }
+ return nullptr;
}
ut_d(if (!(++buf_dbg_counter % 5771)) buf_pool.validate());
@@ -2383,11 +2423,12 @@ ignore_block:
return nullptr;
}
} else if (mode != BUF_PEEK_IF_IN_POOL) {
- } else if (!mtr) {
+ } else if (!mtr) {
ut_ad(!block->page.oldest_modification());
mysql_mutex_lock(&buf_pool.mutex);
block->unfix();
+free_unfixed_block:
if (!buf_LRU_free_page(&block->page, true)) {
ut_ad(0);
}
@@ -2495,20 +2536,19 @@ wait_for_unfix:
/* Decompress the page while not holding
buf_pool.mutex. */
- auto ok = buf_zip_decompress(block, false);
- block->page.read_unfix(state);
- state = block->page.state();
- block->page.lock.x_unlock();
+ const auto ok = buf_zip_decompress(block, false);
--buf_pool.n_pend_unzip;
-
if (!ok) {
- /* FIXME: Evict the corrupted
- ROW_FORMAT=COMPRESSED page! */
-
if (err) {
*err = DB_PAGE_CORRUPTED;
}
- return nullptr;
+ mysql_mutex_lock(&buf_pool.mutex);
+ }
+ state = block->page.read_unfix(state);
+ block->page.lock.x_unlock();
+
+ if (!ok) {
+ goto free_unfixed_block;
}
}
@@ -2606,35 +2646,37 @@ buf_page_get_gen(
mtr_t* mtr,
dberr_t* err)
{
- if (buf_block_t *block= recv_sys.recover(page_id))
+ buf_block_t *block= recv_sys.recover(page_id);
+ if (UNIV_LIKELY(!block))
+ return buf_page_get_low(page_id, zip_size, rw_latch,
+ guess, mode, mtr, err);
+ else if (UNIV_UNLIKELY(block == reinterpret_cast<buf_block_t*>(-1)))
{
- if (UNIV_UNLIKELY(block == reinterpret_cast<buf_block_t*>(-1)))
- {
- corrupted:
- if (err)
- *err= DB_CORRUPTION;
- return nullptr;
- }
- /* Recovery is a special case; we fix() before acquiring lock. */
- auto s= block->page.fix();
- ut_ad(s >= buf_page_t::FREED);
- /* The block may be write-fixed at this point because we are not
- holding a lock, but it must not be read-fixed. */
- ut_ad(s < buf_page_t::READ_FIX || s >= buf_page_t::WRITE_FIX);
- if (s < buf_page_t::UNFIXED)
- {
- ut_ad(mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL);
- block->page.unfix();
- goto corrupted;
- }
+ corrupted:
if (err)
- *err= DB_SUCCESS;
- mtr->page_lock(block, rw_latch);
- return block;
+ *err= DB_CORRUPTION;
+ return nullptr;
+ }
+ if (err)
+ *err= DB_SUCCESS;
+ /* Recovery is a special case; we fix() before acquiring lock. */
+ auto s= block->page.fix();
+ ut_ad(s >= buf_page_t::FREED);
+ /* The block may be write-fixed at this point because we are not
+ holding a lock, but it must not be read-fixed. */
+ ut_ad(s < buf_page_t::READ_FIX || s >= buf_page_t::WRITE_FIX);
+ if (s < buf_page_t::UNFIXED)
+ {
+ ut_ad(mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL);
+ mysql_mutex_lock(&buf_pool.mutex);
+ block->page.unfix();
+ buf_LRU_free_page(&block->page, true);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ goto corrupted;
}
- return buf_page_get_low(page_id, zip_size, rw_latch,
- guess, mode, mtr, err);
+ mtr->page_lock(block, rw_latch);
+ return block;
}
/********************************************************************//**
@@ -2922,12 +2964,12 @@ retry:
buf_unzip_LRU_add_block(reinterpret_cast<buf_block_t*>(bpage), FALSE);
}
+ buf_pool.stat.n_pages_created++;
mysql_mutex_unlock(&buf_pool.mutex);
mtr->memo_push(reinterpret_cast<buf_block_t*>(bpage), MTR_MEMO_PAGE_X_FIX);
bpage->set_accessed();
- buf_pool.stat.n_pages_created++;
static_assert(FIL_PAGE_PREV + 4 == FIL_PAGE_NEXT, "adjacent");
memset_aligned<8>(bpage->frame + FIL_PAGE_PREV, 0xff, 8);
@@ -3145,7 +3187,6 @@ dberr_t buf_page_t::read_complete(const fil_node_t &node)
ut_d(auto n=) buf_pool.n_pend_reads--;
ut_ad(n > 0);
- buf_pool.stat.n_pages_read++;
const byte *read_frame= zip.data ? zip.data : frame;
ut_ad(read_frame);
@@ -3286,9 +3327,6 @@ void buf_pool_invalidate()
{
mysql_mutex_lock(&buf_pool.mutex);
- buf_flush_wait_batch_end(true);
- buf_flush_wait_batch_end(false);
-
/* It is possible that a write batch that has been posted
earlier is still not complete. For buffer pool invalidation to
proceed we must ensure there is NO write activity happening. */
@@ -3439,8 +3477,8 @@ void buf_pool_t::print()
<< UT_LIST_GET_LEN(flush_list)
<< ", n pending decompressions=" << n_pend_unzip
<< ", n pending reads=" << n_pend_reads
- << ", n pending flush LRU=" << n_flush_LRU_
- << " list=" << n_flush_list_
+ << ", n pending flush LRU=" << n_flush()
+ << " list=" << buf_dblwr.pending_writes()
<< ", pages made young=" << stat.n_pages_made_young
<< ", not young=" << stat.n_pages_not_made_young
<< ", pages read=" << stat.n_pages_read
@@ -3552,13 +3590,13 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info)
pool_info->flush_list_len = UT_LIST_GET_LEN(buf_pool.flush_list);
pool_info->n_pend_unzip = UT_LIST_GET_LEN(buf_pool.unzip_LRU);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
pool_info->n_pend_reads = buf_pool.n_pend_reads;
- pool_info->n_pending_flush_lru = buf_pool.n_flush_LRU_;
+ pool_info->n_pending_flush_lru = buf_pool.n_flush();
- pool_info->n_pending_flush_list = buf_pool.n_flush_list_;
+ pool_info->n_pending_flush_list = buf_dblwr.pending_writes();
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time,
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index cbf7885a271..2ea72eb4c5f 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -46,7 +46,17 @@ inline buf_block_t *buf_dblwr_trx_sys_get(mtr_t *mtr)
0, RW_X_LATCH, mtr);
}
-/** Initialize the doublewrite buffer data structure.
+void buf_dblwr_t::init()
+{
+ if (!active_slot)
+ {
+ active_slot= &slots[0];
+ mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr);
+ pthread_cond_init(&cond, nullptr);
+ }
+}
+
+/** Initialise the persistent storage of the doublewrite buffer.
@param header doublewrite page header in the TRX_SYS page */
inline void buf_dblwr_t::init(const byte *header)
{
@@ -54,8 +64,6 @@ inline void buf_dblwr_t::init(const byte *header)
ut_ad(!active_slot->reserved);
ut_ad(!batch_running);
- mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr);
- pthread_cond_init(&cond, nullptr);
block1= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK1));
block2= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK2));
@@ -74,7 +82,7 @@ inline void buf_dblwr_t::init(const byte *header)
@return whether the operation succeeded */
bool buf_dblwr_t::create()
{
- if (is_initialised())
+ if (is_created())
return true;
mtr_t mtr;
@@ -341,7 +349,7 @@ func_exit:
void buf_dblwr_t::recover()
{
ut_ad(log_sys.last_checkpoint_lsn);
- if (!is_initialised())
+ if (!is_created())
return;
uint32_t page_no_dblwr= 0;
@@ -450,10 +458,9 @@ next_page:
/** Free the doublewrite buffer. */
void buf_dblwr_t::close()
{
- if (!is_initialised())
+ if (!active_slot)
return;
- /* Free the double write data structures. */
ut_ad(!active_slot->reserved);
ut_ad(!active_slot->first_free);
ut_ad(!batch_running);
@@ -467,35 +474,41 @@ void buf_dblwr_t::close()
mysql_mutex_destroy(&mutex);
memset((void*) this, 0, sizeof *this);
- active_slot= &slots[0];
}
/** Update the doublewrite buffer on write completion. */
-void buf_dblwr_t::write_completed()
+void buf_dblwr_t::write_completed(bool with_doublewrite)
{
ut_ad(this == &buf_dblwr);
- ut_ad(srv_use_doublewrite_buf);
- ut_ad(is_initialised());
ut_ad(!srv_read_only_mode);
mysql_mutex_lock(&mutex);
- ut_ad(batch_running);
- slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
- ut_ad(flush_slot->reserved);
- ut_ad(flush_slot->reserved <= flush_slot->first_free);
+ ut_ad(writes_pending);
+ if (!--writes_pending)
+ pthread_cond_broadcast(&write_cond);
- if (!--flush_slot->reserved)
+ if (with_doublewrite)
{
- mysql_mutex_unlock(&mutex);
- /* This will finish the batch. Sync data files to the disk. */
- fil_flush_file_spaces();
- mysql_mutex_lock(&mutex);
+ ut_ad(is_created());
+ ut_ad(srv_use_doublewrite_buf);
+ ut_ad(batch_running);
+ slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
+ ut_ad(flush_slot->reserved);
+ ut_ad(flush_slot->reserved <= flush_slot->first_free);
+
+ if (!--flush_slot->reserved)
+ {
+ mysql_mutex_unlock(&mutex);
+ /* This will finish the batch. Sync data files to the disk. */
+ fil_flush_file_spaces();
+ mysql_mutex_lock(&mutex);
- /* We can now reuse the doublewrite memory buffer: */
- flush_slot->first_free= 0;
- batch_running= false;
- pthread_cond_broadcast(&cond);
+ /* We can now reuse the doublewrite memory buffer: */
+ flush_slot->first_free= 0;
+ batch_running= false;
+ pthread_cond_broadcast(&cond);
+ }
}
mysql_mutex_unlock(&mutex);
@@ -640,7 +653,7 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
{
ut_ad(this == &buf_dblwr);
ut_ad(srv_use_doublewrite_buf);
- ut_ad(is_initialised());
+ ut_ad(is_created());
ut_ad(!srv_read_only_mode);
ut_ad(!request.bpage);
ut_ad(request.node == fil_system.sys_space->chain.start);
@@ -706,7 +719,7 @@ posted, and also when we may have to wait for a page latch!
Otherwise a deadlock of threads can occur. */
void buf_dblwr_t::flush_buffered_writes()
{
- if (!is_initialised() || !srv_use_doublewrite_buf)
+ if (!is_created() || !srv_use_doublewrite_buf)
{
fil_flush_file_spaces();
return;
@@ -739,6 +752,7 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
const ulint buf_size= 2 * block_size();
mysql_mutex_lock(&mutex);
+ writes_pending++;
for (;;)
{
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 99b44c0d06e..569096377c0 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -44,15 +44,12 @@ Created 11/11/1995 Heikki Tuuri
#include "snappy-c.h"
/** Number of pages flushed via LRU. Protected by buf_pool.mutex.
-Also included in buf_flush_page_count. */
+Also included in buf_pool.stat.n_pages_written. */
ulint buf_lru_flush_page_count;
/** Number of pages freed without flushing. Protected by buf_pool.mutex. */
ulint buf_lru_freed_page_count;
-/** Number of pages flushed. Protected by buf_pool.mutex. */
-ulint buf_flush_page_count;
-
/** Flag indicating if the page_cleaner is in active state. */
Atomic_relaxed<bool> buf_page_cleaner_is_active;
@@ -112,8 +109,7 @@ static void buf_flush_validate_skip()
}
#endif /* UNIV_DEBUG */
-/** Wake up the page cleaner if needed */
-void buf_pool_t::page_cleaner_wakeup()
+void buf_pool_t::page_cleaner_wakeup(bool for_LRU)
{
ut_d(buf_flush_validate_skip());
if (!page_cleaner_idle())
@@ -147,32 +143,26 @@ void buf_pool_t::page_cleaner_wakeup()
- by allowing last_activity_count to updated when page-cleaner is made
active and has work to do. This ensures that the last_activity signal
is consumed by the page-cleaner before the next one is generated. */
- if ((pct_lwm != 0.0 && pct_lwm <= dirty_pct) ||
- (pct_lwm != 0.0 && last_activity_count == srv_get_activity_count()) ||
+ if (for_LRU ||
+ (pct_lwm != 0.0 && (pct_lwm <= dirty_pct ||
+ last_activity_count == srv_get_activity_count())) ||
srv_max_buf_pool_modified_pct <= dirty_pct)
{
- page_cleaner_is_idle= false;
+ page_cleaner_status-= PAGE_CLEANER_IDLE;
pthread_cond_signal(&do_flush_list);
}
}
-inline void buf_pool_t::delete_from_flush_list_low(buf_page_t *bpage) noexcept
+/** Remove a block from flush_list.
+@param bpage buffer pool page */
+void buf_pool_t::delete_from_flush_list(buf_page_t *bpage) noexcept
{
ut_ad(!fsp_is_system_temporary(bpage->id().space()));
mysql_mutex_assert_owner(&flush_list_mutex);
flush_hp.adjust(bpage);
UT_LIST_REMOVE(flush_list, bpage);
-}
-
-/** Remove a block from flush_list.
-@param bpage buffer pool page
-@param clear whether to invoke buf_page_t::clear_oldest_modification() */
-void buf_pool_t::delete_from_flush_list(buf_page_t *bpage, bool clear) noexcept
-{
- delete_from_flush_list_low(bpage);
- stat.flush_list_bytes-= bpage->physical_size();
- if (clear)
- bpage->clear_oldest_modification();
+ flush_list_bytes-= bpage->physical_size();
+ bpage->clear_oldest_modification();
#ifdef UNIV_DEBUG
buf_flush_validate_skip();
#endif /* UNIV_DEBUG */
@@ -187,10 +177,10 @@ void buf_flush_remove_pages(uint32_t id)
{
const page_id_t first(id, 0), end(id + 1, 0);
ut_ad(id);
- mysql_mutex_lock(&buf_pool.mutex);
for (;;)
{
+ mysql_mutex_lock(&buf_pool.mutex);
bool deferred= false;
mysql_mutex_lock(&buf_pool.flush_list_mutex);
@@ -213,18 +203,14 @@ void buf_flush_remove_pages(uint32_t id)
bpage= prev;
}
+ mysql_mutex_unlock(&buf_pool.mutex);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
if (!deferred)
break;
- mysql_mutex_unlock(&buf_pool.mutex);
- std::this_thread::yield();
- mysql_mutex_lock(&buf_pool.mutex);
- buf_flush_wait_batch_end(false);
+ buf_dblwr.wait_for_page_writes();
}
-
- mysql_mutex_unlock(&buf_pool.mutex);
}
/*******************************************************************//**
@@ -269,7 +255,7 @@ buf_flush_relocate_on_flush_list(
bpage->clear_oldest_modification();
if (lsn == 1) {
- buf_pool.stat.flush_list_bytes -= dpage->physical_size();
+ buf_pool.flush_list_bytes -= dpage->physical_size();
dpage->list.prev = nullptr;
dpage->list.next = nullptr;
dpage->clear_oldest_modification();
@@ -309,6 +295,21 @@ inline void buf_page_t::write_complete(bool temporary)
lock.u_unlock(true);
}
+inline void buf_pool_t::n_flush_inc()
+{
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ page_cleaner_status+= LRU_FLUSH;
+}
+
+inline void buf_pool_t::n_flush_dec()
+{
+ mysql_mutex_lock(&flush_list_mutex);
+ ut_ad(page_cleaner_status >= LRU_FLUSH);
+ if ((page_cleaner_status-= LRU_FLUSH) < LRU_FLUSH)
+ pthread_cond_broadcast(&done_flush_LRU);
+ mysql_mutex_unlock(&flush_list_mutex);
+}
+
/** Complete write of a file page from buf_pool.
@param request write request */
void buf_page_write_complete(const IORequest &request)
@@ -324,13 +325,6 @@ void buf_page_write_complete(const IORequest &request)
ut_ad(!buf_dblwr.is_inside(bpage->id()));
ut_ad(request.node->space->id == bpage->id().space());
- if (state < buf_page_t::WRITE_FIX_REINIT &&
- request.node->space->use_doublewrite())
- {
- ut_ad(request.node->space != fil_system.temp_space);
- buf_dblwr.write_completed();
- }
-
if (request.slot)
request.slot->release();
@@ -338,33 +332,31 @@ void buf_page_write_complete(const IORequest &request)
buf_page_monitor(*bpage, false);
DBUG_PRINT("ib_buf", ("write page %u:%u",
bpage->id().space(), bpage->id().page_no()));
- const bool temp= fsp_is_system_temporary(bpage->id().space());
- mysql_mutex_lock(&buf_pool.mutex);
+ mysql_mutex_assert_not_owner(&buf_pool.mutex);
mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
- buf_pool.stat.n_pages_written++;
- bpage->write_complete(temp);
if (request.is_LRU())
{
+ const bool temp= bpage->oldest_modification() == 2;
+ if (!temp)
+ buf_dblwr.write_completed(state < buf_page_t::WRITE_FIX_REINIT &&
+ request.node->space->use_doublewrite());
+ /* We must hold buf_pool.mutex while releasing the block, so that
+ no other thread can access it before we have freed it. */
+ mysql_mutex_lock(&buf_pool.mutex);
+ bpage->write_complete(temp);
buf_LRU_free_page(bpage, true);
+ mysql_mutex_unlock(&buf_pool.mutex);
- ut_ad(buf_pool.n_flush_LRU_);
- if (!--buf_pool.n_flush_LRU_)
- {
- pthread_cond_broadcast(&buf_pool.done_flush_LRU);
- pthread_cond_signal(&buf_pool.done_free);
- }
+ buf_pool.n_flush_dec();
}
else
{
- ut_ad(!temp);
- ut_ad(buf_pool.n_flush_list_);
- if (!--buf_pool.n_flush_list_)
- pthread_cond_broadcast(&buf_pool.done_flush_list);
+ buf_dblwr.write_completed(state < buf_page_t::WRITE_FIX_REINIT &&
+ request.node->space->use_doublewrite());
+ bpage->write_complete(false);
}
-
- mysql_mutex_unlock(&buf_pool.mutex);
}
/** Calculate a ROW_FORMAT=COMPRESSED page checksum and update the page.
@@ -707,43 +699,41 @@ not_compressed:
}
/** Free a page whose underlying file page has been freed. */
-inline void buf_pool_t::release_freed_page(buf_page_t *bpage) noexcept
+ATTRIBUTE_COLD void buf_pool_t::release_freed_page(buf_page_t *bpage) noexcept
{
mysql_mutex_assert_owner(&mutex);
- mysql_mutex_lock(&flush_list_mutex);
ut_d(const lsn_t oldest_modification= bpage->oldest_modification();)
if (fsp_is_system_temporary(bpage->id().space()))
{
ut_ad(bpage->frame);
ut_ad(oldest_modification == 2);
+ bpage->clear_oldest_modification();
}
else
{
+ mysql_mutex_lock(&flush_list_mutex);
ut_ad(oldest_modification > 2);
- delete_from_flush_list(bpage, false);
+ delete_from_flush_list(bpage);
+ mysql_mutex_unlock(&flush_list_mutex);
}
- bpage->clear_oldest_modification();
- mysql_mutex_unlock(&flush_list_mutex);
- bpage->lock.u_unlock(true);
+ bpage->lock.u_unlock(true);
buf_LRU_free_page(bpage, true);
}
-/** Write a flushable page to a file. buf_pool.mutex must be held.
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list
+/** Write a flushable page to a file or free a freeable block.
+@param evict whether to evict the page on write completion
@param space tablespace
-@return whether the page was flushed and buf_pool.mutex was released */
-inline bool buf_page_t::flush(bool lru, fil_space_t *space)
+@return whether a page write was initiated and buf_pool.mutex released */
+bool buf_page_t::flush(bool evict, fil_space_t *space)
{
+ mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
ut_ad(in_file());
ut_ad(in_LRU_list);
ut_ad((space->purpose == FIL_TYPE_TEMPORARY) ==
(space == fil_system.temp_space));
+ ut_ad(evict || space != fil_system.temp_space);
ut_ad(space->referenced());
- ut_ad(lru || space != fil_system.temp_space);
-
- if (!lock.u_lock_try(true))
- return false;
const auto s= state();
ut_a(s >= FREED);
@@ -751,44 +741,36 @@ inline bool buf_page_t::flush(bool lru, fil_space_t *space)
if (s < UNFIXED)
{
buf_pool.release_freed_page(this);
- mysql_mutex_unlock(&buf_pool.mutex);
- return true;
- }
-
- if (s >= READ_FIX || oldest_modification() < 2)
- {
- lock.u_unlock(true);
return false;
}
- mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
-
- /* Apart from the U-lock, this block will also be protected by
- is_write_fixed() and oldest_modification()>1.
- Thus, it cannot be relocated or removed. */
-
- DBUG_PRINT("ib_buf", ("%s %u page %u:%u",
- lru ? "LRU" : "flush_list",
- id().space(), id().page_no()));
ut_d(const auto f=) zip.fix.fetch_add(WRITE_FIX - UNFIXED);
ut_ad(f >= UNFIXED);
ut_ad(f < READ_FIX);
- ut_ad(space == fil_system.temp_space
+ ut_ad((space == fil_system.temp_space)
? oldest_modification() == 2
: oldest_modification() > 2);
- if (lru)
- {
- ut_ad(buf_pool.n_flush_LRU_ < ULINT_UNDEFINED);
- buf_pool.n_flush_LRU_++;
- }
- else
+
+ /* Increment the I/O operation count used for selecting LRU policy. */
+ buf_LRU_stat_inc_io();
+ mysql_mutex_unlock(&buf_pool.mutex);
+
+ IORequest::Type type= IORequest::WRITE_ASYNC;
+ if (UNIV_UNLIKELY(evict))
{
- ut_ad(buf_pool.n_flush_list_ < ULINT_UNDEFINED);
- buf_pool.n_flush_list_++;
+ type= IORequest::WRITE_LRU;
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_pool.n_flush_inc();
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
}
- buf_flush_page_count++;
- mysql_mutex_unlock(&buf_pool.mutex);
+ /* Apart from the U-lock, this block will also be protected by
+ is_write_fixed() and oldest_modification()>1.
+ Thus, it cannot be relocated or removed. */
+
+ DBUG_PRINT("ib_buf", ("%s %u page %u:%u",
+ evict ? "LRU" : "flush_list",
+ id().space(), id().page_no()));
buf_block_t *block= reinterpret_cast<buf_block_t*>(this);
page_t *write_frame= zip.data;
@@ -798,7 +780,6 @@ inline bool buf_page_t::flush(bool lru, fil_space_t *space)
#if defined HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE || defined _WIN32
size_t orig_size;
#endif
- IORequest::Type type= lru ? IORequest::WRITE_LRU : IORequest::WRITE_ASYNC;
buf_tmp_buffer_t *slot= nullptr;
if (UNIV_UNLIKELY(!frame)) /* ROW_FORMAT=COMPRESSED */
@@ -842,7 +823,10 @@ inline bool buf_page_t::flush(bool lru, fil_space_t *space)
{
switch (space->chain.start->punch_hole) {
case 1:
- type= lru ? IORequest::PUNCH_LRU : IORequest::PUNCH;
+ static_assert(IORequest::PUNCH_LRU - IORequest::PUNCH ==
+ IORequest::WRITE_LRU - IORequest::WRITE_ASYNC, "");
+ type=
+ IORequest::Type(type + (IORequest::PUNCH - IORequest::WRITE_ASYNC));
break;
case 2:
size= orig_size;
@@ -863,24 +847,24 @@ inline bool buf_page_t::flush(bool lru, fil_space_t *space)
ut_ad(lsn >= oldest_modification());
log_write_up_to(lsn, true);
}
+ if (UNIV_LIKELY(space->purpose != FIL_TYPE_TEMPORARY))
+ buf_dblwr.add_unbuffered();
space->io(IORequest{type, this, slot}, physical_offset(), size,
write_frame, this);
}
else
buf_dblwr.add_to_batch(IORequest{this, slot, space->chain.start, type},
size);
-
- /* Increment the I/O operation count used for selecting LRU policy. */
- buf_LRU_stat_inc_io();
return true;
}
/** Check whether a page can be flushed from the buf_pool.
@param id page identifier
@param fold id.fold()
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list
+@param evict true=buf_pool.LRU; false=buf_pool.flush_list
@return whether the page can be flushed */
-static bool buf_flush_check_neighbor(const page_id_t id, ulint fold, bool lru)
+static bool buf_flush_check_neighbor(const page_id_t id, ulint fold,
+ bool evict)
{
mysql_mutex_assert_owner(&buf_pool.mutex);
ut_ad(fold == id.fold());
@@ -892,23 +876,23 @@ static bool buf_flush_check_neighbor(const page_id_t id, ulint fold, bool lru)
if (!bpage)
return false;
- /* We avoid flushing 'non-old' blocks in an LRU flush, because the
+ /* We avoid flushing 'non-old' blocks in an eviction flush, because the
flushed blocks are soon freed */
- if (lru && !bpage->is_old())
+ if (evict && !bpage->is_old())
return false;
- return bpage->oldest_modification() > 1 && bpage->ready_for_flush();
+ return bpage->oldest_modification() > 1 && !bpage->is_io_fixed();
}
/** Check which neighbors of a page can be flushed from the buf_pool.
@param space tablespace
@param id page identifier of a dirty page
@param contiguous whether to consider contiguous areas of pages
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list
+@param evict true=buf_pool.LRU; false=buf_pool.flush_list
@return last page number that can be flushed */
static page_id_t buf_flush_check_neighbors(const fil_space_t &space,
page_id_t &id, bool contiguous,
- bool lru)
+ bool evict)
{
ut_ad(id.page_no() < space.size +
(space.physical_size() == 2048 ? 1
@@ -941,7 +925,7 @@ static page_id_t buf_flush_check_neighbors(const fil_space_t &space,
for (page_id_t i= id - 1;; --i)
{
fold--;
- if (!buf_flush_check_neighbor(i, fold, lru))
+ if (!buf_flush_check_neighbor(i, fold, evict))
{
low= i + 1;
break;
@@ -957,7 +941,7 @@ static page_id_t buf_flush_check_neighbors(const fil_space_t &space,
while (++i < high)
{
++fold;
- if (!buf_flush_check_neighbor(i, fold, lru))
+ if (!buf_flush_check_neighbor(i, fold, evict))
break;
}
@@ -1024,28 +1008,37 @@ uint32_t fil_space_t::flush_freed(bool writable)
and also write zeroes or punch the hole for the freed ranges of pages.
@param space tablespace
@param page_id page identifier
+@param bpage buffer page
@param contiguous whether to consider contiguous areas of pages
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list
+@param evict true=buf_pool.LRU; false=buf_pool.flush_list
@param n_flushed number of pages flushed so far in this batch
@param n_to_flush maximum number of pages we are allowed to flush
@return number of pages flushed */
static ulint buf_flush_try_neighbors(fil_space_t *space,
const page_id_t page_id,
- bool contiguous, bool lru,
+ buf_page_t *bpage,
+ bool contiguous, bool evict,
ulint n_flushed, ulint n_to_flush)
{
ut_ad(space->id == page_id.space());
+ ut_ad(bpage->id() == page_id);
ulint count= 0;
page_id_t id= page_id;
- page_id_t high= buf_flush_check_neighbors(*space, id, contiguous, lru);
+ page_id_t high= buf_flush_check_neighbors(*space, id, contiguous, evict);
ut_ad(page_id >= id);
ut_ad(page_id < high);
- for (ulint id_fold= id.fold(); id < high && !space->is_stopping();
- ++id, ++id_fold)
+ for (ulint id_fold= id.fold(); id < high; ++id, ++id_fold)
{
+ if (UNIV_UNLIKELY(space->is_stopping()))
+ {
+ if (bpage)
+ bpage->lock.u_unlock(true);
+ break;
+ }
+
if (count + n_flushed >= n_to_flush)
{
if (id > page_id)
@@ -1059,25 +1052,38 @@ static ulint buf_flush_try_neighbors(fil_space_t *space,
const buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(id_fold);
mysql_mutex_lock(&buf_pool.mutex);
- if (buf_page_t *bpage= buf_pool.page_hash.get(id, chain))
+ if (buf_page_t *b= buf_pool.page_hash.get(id, chain))
{
- ut_ad(bpage->in_file());
- /* We avoid flushing 'non-old' blocks in an LRU flush,
- because the flushed blocks are soon freed */
- if (!lru || id == page_id || bpage->is_old())
+ ut_ad(b->in_file());
+ if (id == page_id)
{
- if (bpage->oldest_modification() > 1 && bpage->ready_for_flush() &&
- bpage->flush(lru, space))
+ ut_ad(bpage == b);
+ bpage= nullptr;
+ ut_ad(b->oldest_modification() > 1);
+ flush:
+ if (b->flush(evict, space))
{
++count;
continue;
}
}
+ /* We avoid flushing 'non-old' blocks in an eviction flush,
+ because the flushed blocks are soon freed */
+ else if ((!evict || b->is_old()) &&
+ b->oldest_modification() > 1 && b->lock.u_lock_try(true))
+ {
+ if (b->oldest_modification() < 2)
+ b->lock.u_unlock(true);
+ else
+ goto flush;
+ }
}
mysql_mutex_unlock(&buf_pool.mutex);
}
+ ut_ad(!bpage);
+
if (auto n= count - 1)
{
MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE,
@@ -1093,12 +1099,8 @@ This utility moves the uncompressed frames of pages to the free list.
Note that this function does not actually flush any data to disk. It
just detaches the uncompressed frames from the compressed pages at the
tail of the unzip_LRU and puts those freed frames in the free list.
-Note that it is a best effort attempt and it is not guaranteed that
-after a call to this function there will be 'max' blocks in the free
-list.
-@param[in] max desired number of blocks in the free_list
@return number of blocks moved to the free list. */
-static ulint buf_free_from_unzip_LRU_list_batch(ulint max)
+static ulint buf_free_from_unzip_LRU_list_batch()
{
ulint scanned = 0;
ulint count = 0;
@@ -1108,7 +1110,6 @@ static ulint buf_free_from_unzip_LRU_list_batch(ulint max)
buf_block_t* block = UT_LIST_GET_LAST(buf_pool.unzip_LRU);
while (block
- && count < max
&& UT_LIST_GET_LEN(buf_pool.free) < srv_LRU_scan_depth
&& UT_LIST_GET_LEN(buf_pool.unzip_LRU)
> UT_LIST_GET_LEN(buf_pool.LRU) / 10) {
@@ -1155,34 +1156,30 @@ struct flush_counters_t
ulint evicted;
};
-/** Try to discard a dirty page.
+/** Discard a dirty page, and release buf_pool.flush_list_mutex.
@param bpage dirty page whose tablespace is not accessible */
static void buf_flush_discard_page(buf_page_t *bpage)
{
- mysql_mutex_assert_owner(&buf_pool.mutex);
- mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
ut_ad(bpage->in_file());
ut_ad(bpage->oldest_modification());
- if (!bpage->lock.u_lock_try(false))
- return;
-
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_pool.delete_from_flush_list(bpage);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
ut_d(const auto state= bpage->state());
ut_ad(state == buf_page_t::FREED || state == buf_page_t::UNFIXED ||
state == buf_page_t::REINIT);
- bpage->lock.u_unlock();
-
+ bpage->lock.u_unlock(true);
buf_LRU_free_page(bpage, true);
}
-/** Flush dirty blocks from the end of the LRU list.
-@param max maximum number of blocks to make available in buf_pool.free
-@param n counts of flushed and evicted pages */
-static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n)
+/** Flush dirty blocks from the end buf_pool.LRU,
+and move clean blocks to buf_pool.free.
+@param max maximum number of blocks to flush
+@param evict whether dirty pages are to be evicted after flushing them
+@param n counts of flushed and evicted pages */
+static void buf_flush_LRU_list_batch(ulint max, bool evict,
+ flush_counters_t *n)
{
ulint scanned= 0;
ulint free_limit= srv_LRU_scan_depth;
@@ -1201,29 +1198,48 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n)
for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.LRU);
bpage &&
((UT_LIST_GET_LEN(buf_pool.LRU) > BUF_LRU_MIN_LEN &&
- UT_LIST_GET_LEN(buf_pool.free) < free_limit &&
- n->flushed + n->evicted < max) ||
- recv_recovery_is_on()); ++scanned)
+ UT_LIST_GET_LEN(buf_pool.free) < free_limit) ||
+ recv_recovery_is_on());
+ ++scanned, bpage= buf_pool.lru_hp.get())
{
buf_page_t *prev= UT_LIST_GET_PREV(LRU, bpage);
- const lsn_t oldest_modification= bpage->oldest_modification();
buf_pool.lru_hp.set(prev);
- const auto state= bpage->state();
+ auto state= bpage->state();
ut_ad(state >= buf_page_t::FREED);
ut_ad(bpage->in_LRU_list);
- if (oldest_modification <= 1)
- {
+ switch (bpage->oldest_modification()) {
+ case 0:
+ evict:
if (state != buf_page_t::FREED &&
(state >= buf_page_t::READ_FIX || (~buf_page_t::LRU_MASK & state)))
- goto must_skip;
- if (buf_LRU_free_page(bpage, true))
- ++n->evicted;
+ continue;
+ buf_LRU_free_page(bpage, true);
+ ++n->evicted;
+ /* fall through */
+ case 1:
+ continue;
}
- else if (state < buf_page_t::READ_FIX)
+
+ if (state < buf_page_t::READ_FIX && bpage->lock.u_lock_try(true))
{
- /* Block is ready for flush. Dispatch an IO request. The IO
- helper thread will put it on free list in IO completion routine. */
+ ut_ad(!bpage->is_io_fixed());
+ bool do_evict= evict;
+ switch (bpage->oldest_modification()) {
+ case 1:
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_pool.delete_from_flush_list(bpage);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ /* fall through */
+ case 0:
+ bpage->lock.u_unlock(true);
+ goto evict;
+ case 2:
+ /* LRU flushing will always evict pages of the temporary tablespace. */
+ do_evict= true;
+ }
+ /* Block is ready for flush. Dispatch an IO request.
+ If do_evict, the page may be evicted by buf_page_write_complete(). */
const page_id_t page_id(bpage->id());
const uint32_t space_id= page_id.space();
if (!space || space->id != space_id)
@@ -1240,7 +1256,6 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n)
mysql_mutex_lock(&buf_pool.mutex);
if (p.second)
buf_pool.stat.n_pages_written+= p.second;
- goto retry;
}
else
ut_ad(!space);
@@ -1252,27 +1267,33 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n)
}
if (!space)
+ {
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_discard_page(bpage);
+ }
else if (neighbors && space->is_rotational())
{
mysql_mutex_unlock(&buf_pool.mutex);
- n->flushed+= buf_flush_try_neighbors(space, page_id, neighbors == 1,
- true, n->flushed, max);
+ n->flushed+= buf_flush_try_neighbors(space, page_id, bpage,
+ neighbors == 1,
+ do_evict, n->flushed, max);
reacquire_mutex:
mysql_mutex_lock(&buf_pool.mutex);
}
- else if (bpage->flush(true, space))
+ else if (n->flushed >= max && !recv_recovery_is_on())
+ {
+ bpage->lock.u_unlock(true);
+ break;
+ }
+ else if (bpage->flush(do_evict, space))
{
++n->flushed;
goto reacquire_mutex;
}
}
else
- must_skip:
/* Can't evict or dispatch this block. Go to previous. */
ut_ad(buf_pool.lru_hp.is_hp(prev));
- retry:
- bpage= buf_pool.lru_hp.get();
}
buf_pool.lru_hp.set(nullptr);
@@ -1289,26 +1310,21 @@ reacquire_mutex:
/** Flush and move pages from LRU or unzip_LRU list to the free list.
Whether LRU or unzip_LRU is used depends on the state of the system.
-@param max maximum number of blocks to make available in buf_pool.free
-@return number of flushed pages */
-static ulint buf_do_LRU_batch(ulint max)
+@param max maximum number of blocks to flush
+@param evict whether dirty pages are to be evicted after flushing them
+@param n counts of flushed and evicted pages */
+static void buf_do_LRU_batch(ulint max, bool evict, flush_counters_t *n)
{
- const ulint n_unzip_LRU_evicted= buf_LRU_evict_from_unzip_LRU()
- ? buf_free_from_unzip_LRU_list_batch(max)
- : 0;
- flush_counters_t n;
- n.flushed= 0;
- n.evicted= n_unzip_LRU_evicted;
- buf_flush_LRU_list_batch(max, &n);
- mysql_mutex_assert_owner(&buf_pool.mutex);
-
- if (const ulint evicted= n.evicted - n_unzip_LRU_evicted)
- buf_lru_freed_page_count+= evicted;
+ if (buf_LRU_evict_from_unzip_LRU())
+ buf_free_from_unzip_LRU_list_batch();
+ n->evicted= 0;
+ n->flushed= 0;
+ buf_flush_LRU_list_batch(max, evict, n);
- if (n.flushed)
- buf_lru_flush_page_count+= n.flushed;
-
- return n.flushed;
+ mysql_mutex_assert_owner(&buf_pool.mutex);
+ buf_lru_freed_page_count+= n->evicted;
+ buf_lru_flush_page_count+= n->flushed;
+ buf_pool.stat.n_pages_written+= n->flushed;
}
/** This utility flushes dirty blocks from the end of the flush_list.
@@ -1322,6 +1338,7 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
ulint scanned= 0;
mysql_mutex_assert_owner(&buf_pool.mutex);
+ mysql_mutex_assert_owner(&buf_pool.flush_list_mutex);
const auto neighbors= UT_LIST_GET_LEN(buf_pool.LRU) < BUF_LRU_OLD_MIN_LEN
? 0 : srv_flush_neighbors;
@@ -1332,7 +1349,6 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
/* Start from the end of the list looking for a suitable block to be
flushed. */
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
ulint len= UT_LIST_GET_LEN(buf_pool.flush_list);
for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list);
@@ -1343,32 +1359,42 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
break;
ut_ad(bpage->in_file());
- buf_page_t *prev= UT_LIST_GET_PREV(list, bpage);
-
- if (oldest_modification == 1)
{
- buf_pool.delete_from_flush_list(bpage);
- skip:
- bpage= prev;
- continue;
- }
+ buf_page_t *prev= UT_LIST_GET_PREV(list, bpage);
- ut_ad(oldest_modification > 2);
+ if (oldest_modification == 1)
+ {
+ clear:
+ buf_pool.delete_from_flush_list(bpage);
+ skip:
+ bpage= prev;
+ continue;
+ }
- if (!bpage->ready_for_flush())
- goto skip;
+ ut_ad(oldest_modification > 2);
- /* In order not to degenerate this scan to O(n*n) we attempt to
- preserve the pointer position. Any thread that would remove 'prev'
- from buf_pool.flush_list must adjust the hazard pointer.
+ if (!bpage->lock.u_lock_try(true))
+ goto skip;
- Note: A concurrent execution of buf_flush_list_space() may
- terminate this scan prematurely. The buf_pool.n_flush_list()
- should prevent multiple threads from executing
- buf_do_flush_list_batch() concurrently,
- but buf_flush_list_space() is ignoring that. */
- buf_pool.flush_hp.set(prev);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ ut_ad(!bpage->is_io_fixed());
+
+ if (bpage->oldest_modification() == 1)
+ {
+ bpage->lock.u_unlock(true);
+ goto clear;
+ }
+
+ /* In order not to degenerate this scan to O(n*n) we attempt to
+ preserve the pointer position. Any thread that would remove 'prev'
+ from buf_pool.flush_list must adjust the hazard pointer.
+
+ Note: A concurrent execution of buf_flush_list_space() may
+ terminate this scan prematurely. The buf_pool.flush_list_active
+ should prevent multiple threads from executing
+ buf_do_flush_list_batch() concurrently,
+ but buf_flush_list_space() is ignoring that. */
+ buf_pool.flush_hp.set(prev);
+ }
const page_id_t page_id(bpage->id());
const uint32_t space_id= page_id.space();
@@ -1376,8 +1402,6 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
{
if (last_space_id != space_id)
{
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- buf_pool.flush_hp.set(bpage);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
mysql_mutex_unlock(&buf_pool.mutex);
if (space)
@@ -1386,18 +1410,8 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
space= p.first;
last_space_id= space_id;
mysql_mutex_lock(&buf_pool.mutex);
- if (p.second)
- buf_pool.stat.n_pages_written+= p.second;
+ buf_pool.stat.n_pages_written+= p.second;
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- bpage= buf_pool.flush_hp.get();
- if (!bpage)
- break;
- if (bpage->id() != page_id)
- continue;
- buf_pool.flush_hp.set(UT_LIST_GET_PREV(list, bpage));
- if (bpage->oldest_modification() <= 1 || !bpage->ready_for_flush())
- goto next;
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
}
else
ut_ad(!space);
@@ -1410,27 +1424,29 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
if (!space)
buf_flush_discard_page(bpage);
- else if (neighbors && space->is_rotational())
- {
- mysql_mutex_unlock(&buf_pool.mutex);
- count+= buf_flush_try_neighbors(space, page_id, neighbors == 1,
- false, count, max_n);
- reacquire_mutex:
- mysql_mutex_lock(&buf_pool.mutex);
- }
- else if (bpage->flush(false, space))
+ else
{
- ++count;
- goto reacquire_mutex;
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ if (neighbors && space->is_rotational())
+ {
+ mysql_mutex_unlock(&buf_pool.mutex);
+ count+= buf_flush_try_neighbors(space, page_id, bpage, neighbors == 1,
+ false, count, max_n);
+ reacquire_mutex:
+ mysql_mutex_lock(&buf_pool.mutex);
+ }
+ else if (bpage->flush(false, space))
+ {
+ ++count;
+ goto reacquire_mutex;
+ }
}
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- next:
bpage= buf_pool.flush_hp.get();
}
buf_pool.flush_hp.set(nullptr);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
if (space)
space->release();
@@ -1440,76 +1456,86 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn)
MONITOR_FLUSH_BATCH_SCANNED_NUM_CALL,
MONITOR_FLUSH_BATCH_SCANNED_PER_CALL,
scanned);
- if (count)
- MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_BATCH_TOTAL_PAGE,
- MONITOR_FLUSH_BATCH_COUNT,
- MONITOR_FLUSH_BATCH_PAGES,
- count);
- mysql_mutex_assert_owner(&buf_pool.mutex);
return count;
}
-/** Wait until a flush batch ends.
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list */
-void buf_flush_wait_batch_end(bool lru)
+/** Wait until a LRU flush batch ends. */
+void buf_flush_wait_LRU_batch_end()
{
- const auto &n_flush= lru ? buf_pool.n_flush_LRU_ : buf_pool.n_flush_list_;
+ mysql_mutex_assert_owner(&buf_pool.flush_list_mutex);
+ mysql_mutex_assert_not_owner(&buf_pool.mutex);
- if (n_flush)
+ if (buf_pool.n_flush())
{
- auto cond= lru ? &buf_pool.done_flush_LRU : &buf_pool.done_flush_list;
tpool::tpool_wait_begin();
thd_wait_begin(nullptr, THD_WAIT_DISKIO);
do
- my_cond_wait(cond, &buf_pool.mutex.m_mutex);
- while (n_flush);
+ my_cond_wait(&buf_pool.done_flush_LRU,
+ &buf_pool.flush_list_mutex.m_mutex);
+ while (buf_pool.n_flush());
tpool::tpool_wait_end();
thd_wait_end(nullptr);
- pthread_cond_broadcast(cond);
}
}
/** Write out dirty blocks from buf_pool.flush_list.
+The caller must invoke buf_dblwr.flush_buffered_writes()
+after releasing buf_pool.mutex.
@param max_n wished maximum mumber of blocks flushed
@param lsn buf_pool.get_oldest_modification(LSN_MAX) target
@return the number of processed pages
@retval 0 if a buf_pool.flush_list batch is already running */
-static ulint buf_flush_list(ulint max_n= ULINT_UNDEFINED, lsn_t lsn= LSN_MAX)
+static ulint buf_flush_list_holding_mutex(ulint max_n= ULINT_UNDEFINED,
+ lsn_t lsn= LSN_MAX)
{
ut_ad(lsn);
+ mysql_mutex_assert_owner(&buf_pool.mutex);
- if (buf_pool.n_flush_list())
- return 0;
-
- mysql_mutex_lock(&buf_pool.mutex);
- const bool running= buf_pool.n_flush_list_ != 0;
- /* FIXME: we are performing a dirty read of buf_pool.flush_list.count
- while not holding buf_pool.flush_list_mutex */
- if (running || !UT_LIST_GET_LEN(buf_pool.flush_list))
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ if (buf_pool.flush_list_active())
{
- if (!running)
- pthread_cond_broadcast(&buf_pool.done_flush_list);
- mysql_mutex_unlock(&buf_pool.mutex);
+nothing_to_do:
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
return 0;
}
-
- buf_pool.n_flush_list_++;
- const ulint n_flushed= buf_do_flush_list_batch(max_n, lsn);
- const ulint n_flushing= --buf_pool.n_flush_list_;
-
- buf_pool.try_LRU_scan= true;
-
- mysql_mutex_unlock(&buf_pool.mutex);
-
- if (!n_flushing)
+ if (!buf_pool.get_oldest_modification(0))
+ {
pthread_cond_broadcast(&buf_pool.done_flush_list);
+ goto nothing_to_do;
+ }
+ buf_pool.flush_list_set_active();
+ const ulint n_flushed= buf_do_flush_list_batch(max_n, lsn);
+ if (n_flushed)
+ buf_pool.stat.n_pages_written+= n_flushed;
+ buf_pool.flush_list_set_inactive();
+ pthread_cond_broadcast(&buf_pool.done_flush_list);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- buf_dblwr.flush_buffered_writes();
+ if (n_flushed)
+ MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_BATCH_TOTAL_PAGE,
+ MONITOR_FLUSH_BATCH_COUNT,
+ MONITOR_FLUSH_BATCH_PAGES,
+ n_flushed);
DBUG_PRINT("ib_buf", ("flush_list completed, " ULINTPF " pages", n_flushed));
return n_flushed;
}
+/** Write out dirty blocks from buf_pool.flush_list.
+@param max_n wished maximum mumber of blocks flushed
+@param lsn buf_pool.get_oldest_modification(LSN_MAX) target
+@return the number of processed pages
+@retval 0 if a buf_pool.flush_list batch is already running */
+static ulint buf_flush_list(ulint max_n= ULINT_UNDEFINED,
+ lsn_t lsn= LSN_MAX)
+{
+ mysql_mutex_lock(&buf_pool.mutex);
+ ulint n= buf_flush_list_holding_mutex(max_n, lsn);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ buf_dblwr.flush_buffered_writes();
+ return n;
+}
+
/** Try to flush all the dirty pages that belong to a given tablespace.
@param space tablespace
@param n_flushed number of pages written
@@ -1521,6 +1547,7 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
bool may_have_skipped= false;
ulint max_n_flush= srv_io_capacity;
+ ulint n_flush= 0;
bool acquired= space->acquire();
{
@@ -1537,11 +1564,17 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
ut_ad(bpage->in_file());
buf_page_t *prev= UT_LIST_GET_PREV(list, bpage);
- if (bpage->id().space() != space_id);
- else if (bpage->oldest_modification() == 1)
+ if (bpage->oldest_modification() == 1)
+ clear:
buf_pool.delete_from_flush_list(bpage);
- else if (!bpage->ready_for_flush())
+ else if (bpage->id().space() != space_id);
+ else if (!bpage->lock.u_lock_try(true))
may_have_skipped= true;
+ else if (bpage->oldest_modification() == 1)
+ {
+ bpage->lock.u_unlock(true);
+ goto clear;
+ }
else
{
/* In order not to degenerate this scan to O(n*n) we attempt to
@@ -1553,13 +1586,10 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
concurrently. This may terminate our iteration prematurely,
leading us to return may_have_skipped=true. */
buf_pool.flush_hp.set(prev);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
if (!acquired)
- {
was_freed:
buf_flush_discard_page(bpage);
- }
else
{
if (space->is_stopping())
@@ -1568,28 +1598,24 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
acquired= false;
goto was_freed;
}
- if (!bpage->flush(false, space))
- {
- may_have_skipped= true;
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- goto next_after_skip;
- }
- if (n_flushed)
- ++*n_flushed;
- if (!--max_n_flush)
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ if (bpage->flush(false, space))
{
+ ++n_flush;
+ if (!--max_n_flush)
+ {
+ mysql_mutex_lock(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ may_have_skipped= true;
+ goto done;
+ }
mysql_mutex_lock(&buf_pool.mutex);
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- may_have_skipped= true;
- break;
}
- mysql_mutex_lock(&buf_pool.mutex);
}
mysql_mutex_lock(&buf_pool.flush_list_mutex);
if (!buf_pool.flush_hp.is_hp(prev))
may_have_skipped= true;
- next_after_skip:
bpage= buf_pool.flush_hp.get();
continue;
}
@@ -1602,14 +1628,19 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
buf_flush_list_space(). We should always return true from
buf_flush_list_space() if that should be the case; in
buf_do_flush_list_batch() we will simply perform less work. */
-
+done:
buf_pool.flush_hp.set(nullptr);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- buf_pool.try_LRU_scan= true;
+ buf_pool.stat.n_pages_written+= n_flush;
+ buf_pool.try_LRU_scan= true;
+ pthread_cond_broadcast(&buf_pool.done_free);
mysql_mutex_unlock(&buf_pool.mutex);
+ if (n_flushed)
+ *n_flushed= n_flush;
+
if (acquired)
space->release();
@@ -1621,43 +1652,32 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed)
return may_have_skipped;
}
-/** Write out dirty blocks from buf_pool.LRU.
+/** Write out dirty blocks from buf_pool.LRU,
+and move clean blocks to buf_pool.free.
+The caller must invoke buf_dblwr.flush_buffered_writes()
+after releasing buf_pool.mutex.
@param max_n wished maximum mumber of blocks flushed
-@return the number of processed pages
+@param evict whether to evict pages after flushing
+@return evict ? number of processed pages : number of pages written
@retval 0 if a buf_pool.LRU batch is already running */
-ulint buf_flush_LRU(ulint max_n)
+ulint buf_flush_LRU(ulint max_n, bool evict)
{
- if (buf_pool.n_flush_LRU())
- return 0;
-
- log_buffer_flush_to_disk();
-
- mysql_mutex_lock(&buf_pool.mutex);
- if (buf_pool.n_flush_LRU_)
- {
- mysql_mutex_unlock(&buf_pool.mutex);
- return 0;
- }
- buf_pool.n_flush_LRU_++;
-
- ulint n_flushed= buf_do_LRU_batch(max_n);
-
- const ulint n_flushing= --buf_pool.n_flush_LRU_;
+ mysql_mutex_assert_owner(&buf_pool.mutex);
- buf_pool.try_LRU_scan= true;
+ flush_counters_t n;
+ buf_do_LRU_batch(max_n, evict, &n);
- mysql_mutex_unlock(&buf_pool.mutex);
+ ulint pages= n.flushed;
- if (!n_flushing)
+ if (n.evicted)
{
- pthread_cond_broadcast(&buf_pool.done_flush_LRU);
- pthread_cond_signal(&buf_pool.done_free);
+ if (evict)
+ pages+= n.evicted;
+ buf_pool.try_LRU_scan= true;
+ pthread_cond_broadcast(&buf_pool.done_free);
}
- buf_dblwr.flush_buffered_writes();
-
- DBUG_PRINT("ib_buf", ("LRU flush completed, " ULINTPF " pages", n_flushed));
- return n_flushed;
+ return pages;
}
#ifdef HAVE_PMEM
@@ -1931,9 +1951,14 @@ static void buf_flush_wait(lsn_t lsn)
buf_flush_sync_lsn= lsn;
buf_pool.page_cleaner_set_idle(false);
pthread_cond_signal(&buf_pool.do_flush_list);
+ my_cond_wait(&buf_pool.done_flush_list,
+ &buf_pool.flush_list_mutex.m_mutex);
+ if (buf_pool.get_oldest_modification(lsn) >= lsn)
+ break;
}
- my_cond_wait(&buf_pool.done_flush_list,
- &buf_pool.flush_list_mutex.m_mutex);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ buf_dblwr.wait_for_page_writes();
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
}
}
@@ -1953,6 +1978,9 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
if (buf_pool.get_oldest_modification(sync_lsn) < sync_lsn)
{
MONITOR_INC(MONITOR_FLUSH_SYNC_WAITS);
+ thd_wait_begin(nullptr, THD_WAIT_DISKIO);
+ tpool::tpool_wait_begin();
+
#if 1 /* FIXME: remove this, and guarantee that the page cleaner serves us */
if (UNIV_UNLIKELY(!buf_page_cleaner_is_active))
{
@@ -1960,26 +1988,23 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
{
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
ulint n_pages= buf_flush_list(srv_max_io_capacity, sync_lsn);
- buf_flush_wait_batch_end_acquiring_mutex(false);
if (n_pages)
{
MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_SYNC_TOTAL_PAGE,
MONITOR_FLUSH_SYNC_COUNT,
MONITOR_FLUSH_SYNC_PAGES, n_pages);
}
+ buf_dblwr.wait_for_page_writes();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
}
while (buf_pool.get_oldest_modification(sync_lsn) < sync_lsn);
}
else
#endif
- {
- thd_wait_begin(nullptr, THD_WAIT_DISKIO);
- tpool::tpool_wait_begin();
buf_flush_wait(sync_lsn);
- tpool::tpool_wait_end();
- thd_wait_end(nullptr);
- }
+
+ tpool::tpool_wait_end();
+ thd_wait_end(nullptr);
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
@@ -2024,28 +2049,16 @@ ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious)
}
}
-/** Wait for pending flushes to complete. */
-void buf_flush_wait_batch_end_acquiring_mutex(bool lru)
-{
- if (lru ? buf_pool.n_flush_LRU() : buf_pool.n_flush_list())
- {
- mysql_mutex_lock(&buf_pool.mutex);
- buf_flush_wait_batch_end(lru);
- mysql_mutex_unlock(&buf_pool.mutex);
- }
-}
-
/** Conduct checkpoint-related flushing for innodb_flush_sync=ON,
and try to initiate checkpoints until the target is met.
@param lsn minimum value of buf_pool.get_oldest_modification(LSN_MAX) */
ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn)
{
ut_ad(!srv_read_only_mode);
+ mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
for (;;)
{
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
-
if (ulint n_flushed= buf_flush_list(srv_max_io_capacity, lsn))
{
MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_SYNC_TOTAL_PAGE,
@@ -2086,6 +2099,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn)
/* wake up buf_flush_wait() */
pthread_cond_broadcast(&buf_pool.done_flush_list);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
lsn= std::max(lsn, target);
@@ -2136,8 +2150,9 @@ af_get_pct_for_lsn(
/ 7.5));
}
-/** This function is called approximately once every second by the
-page_cleaner thread if innodb_adaptive_flushing=ON.
+/** This function is called approximately once every second by
+buf_flush_page_cleaner() if innodb_max_dirty_pages_pct_lwm>0
+and innodb_adaptive_flushing=ON.
Based on various factors it decides if there is a need to do flushing.
@return number of pages recommended to be flushed
@param last_pages_in number of pages flushed in previous batch
@@ -2175,52 +2190,43 @@ static ulint page_cleaner_flush_pages_recommendation(ulint last_pages_in,
n_pages= std::min<ulint>(srv_io_capacity, dirty_blocks);
}
+func_exit:
+ page_cleaner.flush_pass++;
return n_pages;
}
sum_pages += last_pages_in;
- double time_elapsed = difftime(curr_time, prev_time);
+ const ulint time_elapsed = std::max<ulint>(curr_time - prev_time, 1);
- /* We update our variables every srv_flushing_avg_loops
+ /* We update our variables every innodb_flushing_avg_loops
iterations to smooth out transition in workload. */
if (++n_iterations >= srv_flushing_avg_loops
- || time_elapsed >= static_cast<double>(srv_flushing_avg_loops)) {
+ || time_elapsed >= srv_flushing_avg_loops) {
- if (time_elapsed < 1) {
- time_elapsed = 1;
- }
-
- avg_page_rate = static_cast<ulint>(
- ((static_cast<double>(sum_pages)
- / time_elapsed)
- + static_cast<double>(avg_page_rate)) / 2);
+ avg_page_rate = (sum_pages / time_elapsed + avg_page_rate) / 2;
/* How much LSN we have generated since last call. */
- lsn_rate = static_cast<lsn_t>(
- static_cast<double>(cur_lsn - prev_lsn)
- / time_elapsed);
+ lsn_rate = (cur_lsn - prev_lsn) / time_elapsed;
lsn_avg_rate = (lsn_avg_rate + lsn_rate) / 2;
- ulint flush_tm = page_cleaner.flush_time;
- ulint flush_pass = page_cleaner.flush_pass;
-
- page_cleaner.flush_time = 0;
- page_cleaner.flush_pass = 0;
-
- if (flush_pass) {
- flush_tm /= flush_pass;
+ if (page_cleaner.flush_pass) {
+ page_cleaner.flush_time /= page_cleaner.flush_pass;
}
- MONITOR_SET(MONITOR_FLUSH_ADAPTIVE_AVG_TIME, flush_tm);
- MONITOR_SET(MONITOR_FLUSH_ADAPTIVE_AVG_PASS, flush_pass);
-
prev_lsn = cur_lsn;
prev_time = curr_time;
- n_iterations = 0;
+ MONITOR_SET(MONITOR_FLUSH_ADAPTIVE_AVG_TIME,
+ page_cleaner.flush_time);
+ MONITOR_SET(MONITOR_FLUSH_ADAPTIVE_AVG_PASS,
+ page_cleaner.flush_pass);
+
+ page_cleaner.flush_time = 0;
+ page_cleaner.flush_pass = 0;
+ n_iterations = 0;
sum_pages = 0;
}
@@ -2270,7 +2276,7 @@ static ulint page_cleaner_flush_pages_recommendation(ulint last_pages_in,
MONITOR_SET(MONITOR_FLUSH_PCT_FOR_DIRTY, pct_for_dirty);
MONITOR_SET(MONITOR_FLUSH_PCT_FOR_LSN, pct_for_lsn);
- return(n_pages);
+ goto func_exit;
}
#if defined __aarch64__&&defined __GNUC__&&__GNUC__==4&&!defined __clang__
@@ -2294,8 +2300,6 @@ static void buf_flush_page_cleaner()
timespec abstime;
set_timespec(abstime, 1);
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
-
lsn_t lsn_limit;
ulint last_activity_count= srv_get_activity_count();
@@ -2303,44 +2307,34 @@ static void buf_flush_page_cleaner()
{
lsn_limit= buf_flush_sync_lsn;
- if (UNIV_UNLIKELY(lsn_limit != 0))
+ if (UNIV_UNLIKELY(lsn_limit != 0) && UNIV_LIKELY(srv_flush_sync))
{
-furious_flush:
- if (UNIV_LIKELY(srv_flush_sync))
- {
- buf_flush_sync_for_checkpoint(lsn_limit);
- last_pages= 0;
- set_timespec(abstime, 1);
- continue;
- }
+ furious_flush:
+ buf_flush_sync_for_checkpoint(lsn_limit);
+ last_pages= 0;
+ set_timespec(abstime, 1);
+ continue;
}
+
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ if (buf_pool.ran_out())
+ goto no_wait;
else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED)
break;
- /* If buf pager cleaner is idle and there is no work
- (either dirty pages are all flushed or adaptive flushing
- is not enabled) then opt for non-timed wait */
if (buf_pool.page_cleaner_idle() &&
(!UT_LIST_GET_LEN(buf_pool.flush_list) ||
srv_max_dirty_pages_pct_lwm == 0.0))
- my_cond_wait(&buf_pool.do_flush_list, &buf_pool.flush_list_mutex.m_mutex);
+ /* We are idle; wait for buf_pool.page_cleaner_wakeup() */
+ my_cond_wait(&buf_pool.do_flush_list,
+ &buf_pool.flush_list_mutex.m_mutex);
else
my_cond_timedwait(&buf_pool.do_flush_list,
&buf_pool.flush_list_mutex.m_mutex, &abstime);
-
+ no_wait:
set_timespec(abstime, 1);
- lsn_t soft_lsn_limit= buf_flush_async_lsn;
lsn_limit= buf_flush_sync_lsn;
-
- if (UNIV_UNLIKELY(lsn_limit != 0))
- {
- if (UNIV_LIKELY(srv_flush_sync))
- goto furious_flush;
- }
- else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED)
- break;
-
const lsn_t oldest_lsn= buf_pool.get_oldest_modification(0);
if (!oldest_lsn)
@@ -2351,23 +2345,78 @@ furious_flush:
/* wake up buf_flush_wait() */
pthread_cond_broadcast(&buf_pool.done_flush_list);
}
-unemployed:
+ unemployed:
buf_flush_async_lsn= 0;
+ set_idle:
buf_pool.page_cleaner_set_idle(true);
+ if (UNIV_UNLIKELY(srv_shutdown_state > SRV_SHUTDOWN_INITIATED))
+ break;
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ end_of_batch:
+ buf_dblwr.flush_buffered_writes();
- DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", continue;);
- DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", continue;);
+ do
+ {
+ DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", continue;);
+ DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", continue;);
+ if (!recv_recovery_is_on() &&
+ !srv_startup_is_before_trx_rollback_phase &&
+ srv_operation == SRV_OPERATION_NORMAL)
+ log_checkpoint();
+ }
+ while (false);
+
+ if (!buf_pool.ran_out())
+ continue;
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ }
+
+ lsn_t soft_lsn_limit= buf_flush_async_lsn;
+
+ if (UNIV_UNLIKELY(lsn_limit != 0))
+ {
+ if (srv_flush_sync)
+ goto do_furious_flush;
+ if (oldest_lsn >= lsn_limit)
+ {
+ buf_flush_sync_lsn= 0;
+ pthread_cond_broadcast(&buf_pool.done_flush_list);
+ }
+ else if (lsn_limit > soft_lsn_limit)
+ soft_lsn_limit= lsn_limit;
+ }
+
+ bool idle_flush= false;
+ ulint n_flushed= 0, n;
+
+ if (UNIV_UNLIKELY(soft_lsn_limit != 0))
+ {
+ if (oldest_lsn >= soft_lsn_limit)
+ buf_flush_async_lsn= soft_lsn_limit= 0;
+ }
+ else if (buf_pool.ran_out())
+ {
+ buf_pool.page_cleaner_set_idle(false);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ n= srv_max_io_capacity;
+ mysql_mutex_lock(&buf_pool.mutex);
+ LRU_flush:
+ n= buf_flush_LRU(n, false);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ last_pages+= n;
- if (!recv_recovery_is_on() &&
- !srv_startup_is_before_trx_rollback_phase &&
- srv_operation == SRV_OPERATION_NORMAL)
- log_checkpoint();
+ if (!idle_flush)
+ goto end_of_batch;
+ /* when idle flushing kicks in page_cleaner is marked active.
+ reset it back to idle since the it was made active as part of
+ idle flushing stage. */
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- continue;
+ goto set_idle;
}
+ else if (UNIV_UNLIKELY(srv_shutdown_state > SRV_SHUTDOWN_INITIATED))
+ break;
const ulint dirty_blocks= UT_LIST_GET_LEN(buf_pool.flush_list);
ut_ad(dirty_blocks);
@@ -2376,94 +2425,71 @@ unemployed:
guaranteed to be nonempty, and it is a subset of buf_pool.LRU. */
const double dirty_pct= double(dirty_blocks) * 100.0 /
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
-
- bool idle_flush= false;
-
- if (lsn_limit || soft_lsn_limit);
- else if (af_needed_for_redo(oldest_lsn));
- else if (srv_max_dirty_pages_pct_lwm != 0.0)
+ if (srv_max_dirty_pages_pct_lwm != 0.0)
{
const ulint activity_count= srv_get_activity_count();
if (activity_count != last_activity_count)
+ {
last_activity_count= activity_count;
+ goto maybe_unemployed;
+ }
else if (buf_pool.page_cleaner_idle() && buf_pool.n_pend_reads == 0)
{
- /* reaching here means 3 things:
- - last_activity_count == activity_count: suggesting server is idle
- (no trx_t::commit activity)
- - page cleaner is idle (dirty_pct < srv_max_dirty_pages_pct_lwm)
- - there are no pending reads but there are dirty pages to flush */
- idle_flush= true;
+ /* reaching here means 3 things:
+ - last_activity_count == activity_count: suggesting server is idle
+ (no trx_t::commit() activity)
+ - page cleaner is idle (dirty_pct < srv_max_dirty_pages_pct_lwm)
+ - there are no pending reads but there are dirty pages to flush */
buf_pool.update_last_activity_count(activity_count);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ idle_flush= true;
+ goto idle_flush;
}
-
- if (!idle_flush && dirty_pct < srv_max_dirty_pages_pct_lwm)
- goto unemployed;
+ else
+ maybe_unemployed:
+ if (dirty_pct < srv_max_dirty_pages_pct_lwm)
+ goto possibly_unemployed;
}
else if (dirty_pct < srv_max_buf_pool_modified_pct)
- goto unemployed;
-
- if (UNIV_UNLIKELY(lsn_limit != 0) && oldest_lsn >= lsn_limit)
- lsn_limit= buf_flush_sync_lsn= 0;
- if (UNIV_UNLIKELY(soft_lsn_limit != 0) && oldest_lsn >= soft_lsn_limit)
- soft_lsn_limit= buf_flush_async_lsn= 0;
+ possibly_unemployed:
+ if (!soft_lsn_limit && !af_needed_for_redo(oldest_lsn))
+ goto unemployed;
buf_pool.page_cleaner_set_idle(false);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- if (!lsn_limit)
- lsn_limit= soft_lsn_limit;
-
- ulint n_flushed;
-
- if (UNIV_UNLIKELY(lsn_limit != 0))
+ if (UNIV_UNLIKELY(soft_lsn_limit != 0))
{
- n_flushed= buf_flush_list(srv_max_io_capacity, lsn_limit);
- /* wake up buf_flush_wait() */
- pthread_cond_broadcast(&buf_pool.done_flush_list);
- goto try_checkpoint;
+ n= srv_max_io_capacity;
+ goto background_flush;
}
- else if (idle_flush || !srv_adaptive_flushing)
+
+ if (!srv_adaptive_flushing)
{
- n_flushed= buf_flush_list(srv_io_capacity);
-try_checkpoint:
- if (n_flushed)
- {
- MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE,
- MONITOR_FLUSH_BACKGROUND_COUNT,
- MONITOR_FLUSH_BACKGROUND_PAGES,
- n_flushed);
-do_checkpoint:
- /* The periodic log_checkpoint() call here makes it harder to
- reproduce bugs in crash recovery or mariabackup --prepare, or
- in code that writes the redo log records. Omitting the call
- here should not affect correctness, because log_free_check()
- should still be invoking checkpoints when needed. */
- DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", goto next;);
- DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", goto next;);
-
- if (!recv_recovery_is_on() && srv_operation == SRV_OPERATION_NORMAL)
- log_checkpoint();
- }
+ idle_flush:
+ n= srv_io_capacity;
+ soft_lsn_limit= LSN_MAX;
+ background_flush:
+ mysql_mutex_lock(&buf_pool.mutex);
+ n_flushed= buf_flush_list_holding_mutex(n, soft_lsn_limit);
+ MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE,
+ MONITOR_FLUSH_BACKGROUND_COUNT,
+ MONITOR_FLUSH_BACKGROUND_PAGES,
+ n_flushed);
}
- else if (ulint n= page_cleaner_flush_pages_recommendation(last_pages,
- oldest_lsn,
- dirty_blocks,
- dirty_pct))
+ else if ((n= page_cleaner_flush_pages_recommendation(last_pages,
+ oldest_lsn,
+ dirty_blocks,
+ dirty_pct)) != 0)
{
- page_cleaner.flush_pass++;
const ulint tm= ut_time_ms();
- last_pages= n_flushed= buf_flush_list(n);
+ mysql_mutex_lock(&buf_pool.mutex);
+ last_pages= n_flushed= buf_flush_list_holding_mutex(n);
page_cleaner.flush_time+= ut_time_ms() - tm;
-
- if (n_flushed)
- {
- MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE,
- MONITOR_FLUSH_ADAPTIVE_COUNT,
- MONITOR_FLUSH_ADAPTIVE_PAGES,
- n_flushed);
- goto do_checkpoint;
- }
+ MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE,
+ MONITOR_FLUSH_ADAPTIVE_COUNT,
+ MONITOR_FLUSH_ADAPTIVE_PAGES,
+ n_flushed);
}
else if (buf_flush_async_lsn <= oldest_lsn)
{
@@ -2471,30 +2497,29 @@ do_checkpoint:
goto unemployed;
}
-#ifndef DBUG_OFF
-next:
-#endif /* !DBUG_OFF */
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
-
- /* when idle flushing kicks in page_cleaner is marked active.
- reset it back to idle since the it was made active as part of
- idle flushing stage. */
- if (idle_flush)
- buf_pool.page_cleaner_set_idle(true);
+ n= n >= n_flushed ? n - n_flushed : 0;
+ goto LRU_flush;
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
if (srv_fast_shutdown != 2)
{
- buf_flush_wait_batch_end_acquiring_mutex(true);
- buf_flush_wait_batch_end_acquiring_mutex(false);
+ buf_dblwr.flush_buffered_writes();
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_flush_wait_LRU_batch_end();
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ buf_dblwr.wait_for_page_writes();
}
mysql_mutex_lock(&buf_pool.flush_list_mutex);
lsn_limit= buf_flush_sync_lsn;
if (UNIV_UNLIKELY(lsn_limit != 0))
+ {
+ do_furious_flush:
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
goto furious_flush;
+ }
buf_page_cleaner_is_active= false;
pthread_cond_broadcast(&buf_pool.done_flush_list);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
@@ -2519,17 +2544,6 @@ ATTRIBUTE_COLD void buf_flush_page_cleaner_init()
std::thread(buf_flush_page_cleaner).detach();
}
-#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY)
-/** @return the number of dirty pages in the buffer pool */
-static ulint buf_flush_list_length()
-{
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- const ulint len= UT_LIST_GET_LEN(buf_pool.flush_list);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- return len;
-}
-#endif
-
/** Flush the buffer pool on shutdown. */
ATTRIBUTE_COLD void buf_flush_buffer_pool()
{
@@ -2545,20 +2559,19 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool()
{
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
buf_flush_list(srv_max_io_capacity);
- if (buf_pool.n_flush_list())
+ if (const size_t pending= buf_dblwr.pending_writes())
{
timespec abstime;
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
- "Waiting to flush " ULINTPF " pages",
- buf_flush_list_length());
+ "Waiting to write %zu pages", pending);
set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2);
- mysql_mutex_lock(&buf_pool.mutex);
- while (buf_pool.n_flush_list_)
- my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex,
- &abstime);
- mysql_mutex_unlock(&buf_pool.mutex);
+ buf_dblwr.wait_for_page_writes(abstime);
}
+
mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
+ "Waiting to flush " ULINTPF " pages",
+ UT_LIST_GET_LEN(buf_pool.flush_list));
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
@@ -2603,6 +2616,7 @@ void buf_flush_sync()
if (lsn == log_sys.get_lsn())
break;
}
+
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
tpool::tpool_wait_end();
thd_wait_end(nullptr);
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index 6c994b8c9bd..e4e20e8335f 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -136,7 +136,6 @@ static void buf_LRU_block_free_hashed_page(buf_block_t *block)
@param[in] bpage control block */
static inline void incr_LRU_size_in_bytes(const buf_page_t* bpage)
{
- /* FIXME: use atomics, not mutex */
mysql_mutex_assert_owner(&buf_pool.mutex);
buf_pool.stat.LRU_bytes += bpage->physical_size();
@@ -401,8 +400,10 @@ buf_block_t* buf_LRU_get_free_block(buf_LRU_get get)
DBUG_EXECUTE_IF("recv_ran_out_of_buffer",
if (recv_recovery_is_on()
&& recv_sys.apply_log_recs) {
+ mysql_mutex_lock(&buf_pool.mutex);
goto flush_lru;
});
+get_mutex:
mysql_mutex_lock(&buf_pool.mutex);
got_mutex:
buf_LRU_check_size_of_non_data_objects();
@@ -451,20 +452,32 @@ got_block:
if ((block = buf_LRU_get_free_only()) != nullptr) {
goto got_block;
}
- if (!buf_pool.n_flush_LRU_) {
- break;
+ mysql_mutex_unlock(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ const auto n_flush = buf_pool.n_flush();
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
+ if (!n_flush) {
+ goto not_found;
+ }
+ if (!buf_pool.try_LRU_scan) {
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_pool.page_cleaner_wakeup(true);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ my_cond_wait(&buf_pool.done_free,
+ &buf_pool.mutex.m_mutex);
}
- my_cond_wait(&buf_pool.done_free, &buf_pool.mutex.m_mutex);
}
-#ifndef DBUG_OFF
not_found:
-#endif
- mysql_mutex_unlock(&buf_pool.mutex);
+ if (n_iterations > 1) {
+ MONITOR_INC( MONITOR_LRU_GET_FREE_WAITS );
+ }
- if (n_iterations > 20 && !buf_lru_free_blocks_error_printed
+ if (n_iterations == 21 && !buf_lru_free_blocks_error_printed
&& srv_buf_pool_old_size == srv_buf_pool_size) {
-
+ buf_lru_free_blocks_error_printed = true;
+ mysql_mutex_unlock(&buf_pool.mutex);
ib::warn() << "Difficult to find free blocks in the buffer pool"
" (" << n_iterations << " search iterations)! "
<< flush_failures << " failed attempts to"
@@ -476,12 +489,7 @@ not_found:
<< os_n_file_writes << " OS file writes, "
<< os_n_fsyncs
<< " OS fsyncs.";
-
- buf_lru_free_blocks_error_printed = true;
- }
-
- if (n_iterations > 1) {
- MONITOR_INC( MONITOR_LRU_GET_FREE_WAITS );
+ mysql_mutex_lock(&buf_pool.mutex);
}
/* No free block was found: try to flush the LRU list.
@@ -495,15 +503,16 @@ not_found:
#ifndef DBUG_OFF
flush_lru:
#endif
- if (!buf_flush_LRU(innodb_lru_flush_size)) {
+ if (!buf_flush_LRU(innodb_lru_flush_size, true)) {
MONITOR_INC(MONITOR_LRU_SINGLE_FLUSH_FAILURE_COUNT);
++flush_failures;
}
n_iterations++;
- mysql_mutex_lock(&buf_pool.mutex);
buf_pool.stat.LRU_waits++;
- goto got_mutex;
+ mysql_mutex_unlock(&buf_pool.mutex);
+ buf_dblwr.flush_buffered_writes();
+ goto get_mutex;
}
/** Move the LRU_old pointer so that the length of the old blocks list
@@ -812,50 +821,57 @@ bool buf_LRU_free_page(buf_page_t *bpage, bool zip)
/* We cannot use transactional_lock_guard here,
because buf_buddy_relocate() in buf_buddy_free() could get stuck. */
hash_lock.lock();
- lsn_t oldest_modification = bpage->oldest_modification_acquire();
+ const lsn_t oldest_modification = bpage->oldest_modification_acquire();
if (UNIV_UNLIKELY(!bpage->can_relocate())) {
/* Do not free buffer fixed and I/O-fixed blocks. */
goto func_exit;
}
- if (oldest_modification == 1) {
+ switch (oldest_modification) {
+ case 2:
+ ut_ad(id.space() == SRV_TMP_SPACE_ID);
+ ut_ad(!bpage->zip.data);
+ if (!bpage->is_freed()) {
+ goto func_exit;
+ }
+ bpage->clear_oldest_modification();
+ break;
+ case 1:
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- oldest_modification = bpage->oldest_modification();
- if (oldest_modification) {
- ut_ad(oldest_modification == 1);
+ if (const lsn_t om = bpage->oldest_modification()) {
+ ut_ad(om == 1);
buf_pool.delete_from_flush_list(bpage);
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
ut_ad(!bpage->oldest_modification());
- oldest_modification = 0;
- }
-
- if (zip || !bpage->zip.data) {
- /* This would completely free the block. */
- /* Do not completely free dirty blocks. */
-
- if (oldest_modification) {
- goto func_exit;
+ /* fall through */
+ case 0:
+ if (zip || !bpage->zip.data || !bpage->frame) {
+ break;
}
- } else if (oldest_modification && !bpage->frame) {
-func_exit:
- hash_lock.unlock();
- return(false);
-
- } else if (bpage->frame) {
+relocate_compressed:
b = static_cast<buf_page_t*>(ut_zalloc_nokey(sizeof *b));
ut_a(b);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
new (b) buf_page_t(*bpage);
b->frame = nullptr;
b->set_state(buf_page_t::UNFIXED + 1);
+ break;
+ default:
+ if (zip || !bpage->zip.data || !bpage->frame) {
+ /* This would completely free the block. */
+ /* Do not completely free dirty blocks. */
+func_exit:
+ hash_lock.unlock();
+ return(false);
+ }
+ goto relocate_compressed;
}
mysql_mutex_assert_owner(&buf_pool.mutex);
- DBUG_PRINT("ib_buf", ("free page %u:%u",
- id.space(), id.page_no()));
+ DBUG_PRINT("ib_buf", ("free page %u:%u", id.space(), id.page_no()));
ut_ad(bpage->can_relocate());
@@ -1026,7 +1042,8 @@ buf_LRU_block_free_non_file_page(
} else {
UT_LIST_ADD_FIRST(buf_pool.free, &block->page);
ut_d(block->page.in_free_list = true);
- pthread_cond_signal(&buf_pool.done_free);
+ buf_pool.try_LRU_scan= true;
+ pthread_cond_broadcast(&buf_pool.done_free);
}
block->page.set_os_unused();
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index 3906ff65dfb..bbd905365ed 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -186,6 +186,7 @@ page_exists:
buf_LRU_add_block(bpage, true/* to old blocks */);
}
+ buf_pool.stat.n_pages_read++;
mysql_mutex_unlock(&buf_pool.mutex);
buf_pool.n_pend_reads++;
return bpage;
@@ -205,35 +206,31 @@ flag is cleared and the x-lock released by an i/o-handler thread.
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0,
bitwise-ORed with 1 in recovery
@param[in,out] chain buf_pool.page_hash cell for page_id
-@param[out] err DB_SUCCESS or DB_TABLESPACE_DELETED
- if we are trying
- to read from a non-existent tablespace
@param[in,out] space tablespace
@param[in,out] block preallocated buffer block
@param[in] sync true if synchronous aio is desired
-@return whether a read request was enqueued */
+@return error code
+@retval DB_SUCCESS if the page was read
+@retval DB_SUCCESS_LOCKED_REC if the page exists in the buffer pool already */
static
-bool
+dberr_t
buf_read_page_low(
const page_id_t page_id,
ulint zip_size,
buf_pool_t::hash_chain& chain,
- dberr_t* err,
fil_space_t* space,
buf_block_t*& block,
bool sync = false)
{
buf_page_t* bpage;
- *err = DB_SUCCESS;
-
ut_ad(!buf_dblwr.is_inside(page_id));
bpage = buf_page_init_for_read(page_id, zip_size, chain, block);
if (!bpage) {
space->release();
- return false;
+ return DB_SUCCESS_LOCKED_REC;
}
ut_ad(bpage->in_file());
@@ -253,7 +250,6 @@ buf_read_page_low(
? IORequest::READ_SYNC
: IORequest::READ_ASYNC),
page_id.page_no() * len, len, dst, bpage);
- *err = fio.err;
if (UNIV_UNLIKELY(fio.err != DB_SUCCESS)) {
ut_d(auto n=) buf_pool.n_pend_reads--;
@@ -262,14 +258,14 @@ buf_read_page_low(
} else if (sync) {
thd_wait_end(NULL);
/* The i/o was already completed in space->io() */
- *err = bpage->read_complete(*fio.node);
+ fio.err = bpage->read_complete(*fio.node);
space->release();
- if (*err == DB_FAIL) {
- *err = DB_PAGE_CORRUPTED;
+ if (fio.err == DB_FAIL) {
+ fio.err = DB_PAGE_CORRUPTED;
}
}
- return true;
+ return fio.err;
}
/** Acquire a buffer block. */
@@ -353,9 +349,8 @@ read_ahead:
if (space->is_stopping())
break;
buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(i.fold());
- dberr_t err;
space->reacquire();
- if (buf_read_page_low(i, zip_size, chain, &err, space, block))
+ if (buf_read_page_low(i, zip_size, chain, space, block) == DB_SUCCESS)
{
count++;
ut_ad(!block);
@@ -365,18 +360,20 @@ read_ahead:
}
if (count)
+ {
DBUG_PRINT("ib_buf", ("random read-ahead %zu pages from %s: %u",
count, space->chain.start->name,
low.page_no()));
- space->release();
+ mysql_mutex_lock(&buf_pool.mutex);
+ /* Read ahead is considered one I/O operation for the purpose of
+ LRU policy decision. */
+ buf_LRU_stat_inc_io();
+ buf_pool.stat.n_ra_pages_read_rnd+= count;
+ mysql_mutex_unlock(&buf_pool.mutex);
+ }
- /* Read ahead is considered one I/O operation for the purpose of
- LRU policy decision. */
- buf_LRU_stat_inc_io();
+ space->release();
buf_read_release(block);
-
- buf_pool.stat.n_ra_pages_read_rnd+= count;
- srv_stats.buf_pool_reads.add(count);
return count;
}
@@ -388,6 +385,7 @@ released by the i/o-handler thread.
@param zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param chain buf_pool.page_hash cell for page_id
@retval DB_SUCCESS if the page was read and is not corrupted,
+@retval DB_SUCCESS_LOCKED_REC if the page was not read
@retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted,
@retval DB_DECRYPTION_FAILED if page post encryption checksum matches but
after decryption normal page checksum does not match.
@@ -403,22 +401,19 @@ dberr_t buf_read_page(const page_id_t page_id, ulint zip_size,
return DB_TABLESPACE_DELETED;
}
- buf_block_t *block= zip_size
- ? nullptr
- : buf_LRU_get_free_block(have_no_mutex);
-
/* Our caller should already have ensured that the page does not
exist in buf_pool.page_hash. */
- dberr_t err;
- if (buf_read_page_low(page_id, zip_size, chain, &err, space, block, true))
+ buf_block_t *block= nullptr;
+ if (UNIV_LIKELY(!zip_size))
{
- ut_ad(!block);
- srv_stats.buf_pool_reads.add(1);
+ mysql_mutex_lock(&buf_pool.mutex);
+ buf_LRU_stat_inc_io();
+ block= buf_LRU_get_free_block(have_mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
}
- else
- buf_read_release(block);
- buf_LRU_stat_inc_io();
+ dberr_t err= buf_read_page_low(page_id, zip_size, chain, space, block, true);
+ buf_read_release(block);
return err;
}
@@ -444,12 +439,9 @@ void buf_read_page_background(fil_space_t *space, const page_id_t page_id,
if (!zip_size && !(block= buf_read_acquire()))
goto skip;
- dberr_t err;
- if (buf_read_page_low(page_id, zip_size, chain, &err, space, block))
- {
+ if (buf_read_page_low(page_id, zip_size, chain, space, block) ==
+ DB_SUCCESS)
ut_ad(!block);
- srv_stats.buf_pool_reads.add(1);
- }
else
buf_read_release(block);
@@ -601,9 +593,9 @@ failed:
if (space->is_stopping())
break;
buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(new_low.fold());
- dberr_t err;
space->reacquire();
- if (buf_read_page_low(new_low, zip_size, chain, &err, space, block))
+ if (buf_read_page_low(new_low, zip_size, chain, space, block) ==
+ DB_SUCCESS)
{
count++;
ut_ad(!block);
@@ -613,17 +605,20 @@ failed:
}
if (count)
+ {
DBUG_PRINT("ib_buf", ("random read-ahead %zu pages from %s: %u",
count, space->chain.start->name,
new_low.page_no()));
- space->release();
+ mysql_mutex_lock(&buf_pool.mutex);
+ /* Read ahead is considered one I/O operation for the purpose of
+ LRU policy decision. */
+ buf_LRU_stat_inc_io();
+ buf_pool.stat.n_ra_pages_read+= count;
+ mysql_mutex_unlock(&buf_pool.mutex);
+ }
- /* Read ahead is considered one I/O operation for the purpose of
- LRU policy decision. */
- buf_LRU_stat_inc_io();
+ space->release();
buf_read_release(block);
-
- buf_pool.stat.n_ra_pages_read+= count;
return count;
}
@@ -679,20 +674,22 @@ void buf_read_recv_pages(uint32_t space_id, st_::span<uint32_t> page_nos)
buf_pool_t::hash_chain& chain =
buf_pool.page_hash.cell_get(cur_page_id.fold());
- dberr_t err;
space->reacquire();
- if (buf_read_page_low(cur_page_id, zip_size, chain, &err, space,
- block)) {
+ switch (buf_read_page_low(cur_page_id, zip_size, chain, space,
+ block)) {
+ case DB_SUCCESS:
ut_ad(!block);
block = buf_LRU_get_free_block(have_no_mutex);
- }
-
- if (err != DB_SUCCESS) {
+ break;
+ case DB_SUCCESS_LOCKED_REC:
+ break;
+ default:
sql_print_error("InnoDB: Recovery failed to read page "
UINT32PF " from %s",
cur_page_id.page_no(),
space->chain.start->name);
}
+ ut_ad(block);
}
DBUG_PRINT("ib_buf", ("recovery read (%zu pages) for %s",
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 86792c2680f..c1fd916be55 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -118,6 +118,9 @@ bool fil_space_t::try_to_close(bool print_info)
}
node->close();
+
+ fil_system.move_closed_last_to_space_list(node->space);
+
return true;
}
@@ -392,13 +395,7 @@ static bool fil_node_open_file_low(fil_node_t *node)
ut_ad(node->is_open());
- if (UNIV_LIKELY(!fil_system.freeze_space_list))
- {
- /* Move the file last in fil_system.space_list, so that
- fil_space_t::try_to_close() should close it as a last resort. */
- fil_system.space_list.erase(space_list_t::iterator(node->space));
- fil_system.space_list.push_back(*node->space);
- }
+ fil_system.move_opened_last_to_space_list(node->space);
fil_system.n_open++;
return true;
@@ -797,7 +794,17 @@ pfs_os_file_t fil_system_t::detach(fil_space_t *space, bool detach_handle)
space->is_in_default_encrypt= false;
default_encrypt_tables.remove(*space);
}
- space_list.erase(space_list_t::iterator(space));
+
+ {
+ space_list_t::iterator s= space_list_t::iterator(space);
+ if (space_list_last_opened == space)
+ {
+ space_list_t::iterator prev= s;
+ space_list_last_opened= &*--prev;
+ }
+ space_list.erase(s);
+ }
+
if (space == sys_space)
sys_space= nullptr;
else if (space == temp_space)
@@ -916,12 +923,14 @@ bool fil_space_free(uint32_t id, bool x_latched)
@param purpose tablespace purpose
@param crypt_data encryption information
@param mode encryption mode
+@param opened true if space files are opened
@return pointer to created tablespace, to be filled in with add()
@retval nullptr on failure (such as when the same tablespace exists) */
fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
fil_type_t purpose,
fil_space_crypt_t *crypt_data,
- fil_encryption_t mode)
+ fil_encryption_t mode,
+ bool opened)
{
fil_space_t* space;
@@ -974,7 +983,10 @@ fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
HASH_INSERT(fil_space_t, hash, &fil_system.spaces, id, space);
- fil_system.space_list.push_back(*space);
+ if (opened)
+ fil_system.add_opened_last_to_space_list(space);
+ else
+ fil_system.space_list.push_back(*space);
switch (id) {
case 0:
@@ -1295,6 +1307,15 @@ void fil_system_t::close()
#endif /* __linux__ */
}
+void fil_system_t::add_opened_last_to_space_list(fil_space_t *space)
+{
+ if (UNIV_LIKELY(space_list_last_opened != nullptr))
+ space_list.insert(space_list_t::iterator(space_list_last_opened), *space);
+ else
+ space_list.push_back(*space);
+ space_list_last_opened= space;
+}
+
/** Extend all open data files to the recovered size */
ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size()
{
@@ -2028,7 +2049,7 @@ err_exit:
if (fil_space_t* space = fil_space_t::create(space_id, flags,
FIL_TYPE_TABLESPACE,
- crypt_data, mode)) {
+ crypt_data, mode, true)) {
fil_node_t* node = space->add(path, file, size, false, true);
IF_WIN(node->find_metadata(), node->find_metadata(file, true));
mtr.start();
diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc
index 28e8359cab4..60218a132c9 100644
--- a/storage/innobase/gis/gis0rtree.cc
+++ b/storage/innobase/gis/gis0rtree.cc
@@ -890,6 +890,8 @@ rtr_page_split_and_insert(
int first_rec_group = 1;
IF_DBUG(bool iterated = false,);
+ buf_pool.pages_split++;
+
if (!*heap) {
*heap = mem_heap_create(1024);
}
@@ -1197,8 +1199,6 @@ after_insert:
ut_ad(!rec || rec_offs_validate(rec, cursor->index(), *offsets));
#endif
- MONITOR_INC(MONITOR_INDEX_SPLIT);
-
return(rec);
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index e819b66b898..48b2c668372 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -914,43 +914,37 @@ static SHOW_VAR innodb_status_variables[]= {
(char*) &export_vars.innodb_buffer_pool_resize_status, SHOW_CHAR},
{"buffer_pool_load_incomplete",
&export_vars.innodb_buffer_pool_load_incomplete, SHOW_BOOL},
- {"buffer_pool_pages_data",
- &export_vars.innodb_buffer_pool_pages_data, SHOW_SIZE_T},
+ {"buffer_pool_pages_data", &UT_LIST_GET_LEN(buf_pool.LRU), SHOW_SIZE_T},
{"buffer_pool_bytes_data",
&export_vars.innodb_buffer_pool_bytes_data, SHOW_SIZE_T},
{"buffer_pool_pages_dirty",
- &export_vars.innodb_buffer_pool_pages_dirty, SHOW_SIZE_T},
- {"buffer_pool_bytes_dirty",
- &export_vars.innodb_buffer_pool_bytes_dirty, SHOW_SIZE_T},
- {"buffer_pool_pages_flushed", &buf_flush_page_count, SHOW_SIZE_T},
- {"buffer_pool_pages_free",
- &export_vars.innodb_buffer_pool_pages_free, SHOW_SIZE_T},
+ &UT_LIST_GET_LEN(buf_pool.flush_list), SHOW_SIZE_T},
+ {"buffer_pool_bytes_dirty", &buf_pool.flush_list_bytes, SHOW_SIZE_T},
+ {"buffer_pool_pages_flushed", &buf_pool.stat.n_pages_written, SHOW_SIZE_T},
+ {"buffer_pool_pages_free", &UT_LIST_GET_LEN(buf_pool.free), SHOW_SIZE_T},
#ifdef UNIV_DEBUG
{"buffer_pool_pages_latched",
&export_vars.innodb_buffer_pool_pages_latched, SHOW_SIZE_T},
#endif /* UNIV_DEBUG */
{"buffer_pool_pages_made_not_young",
- &export_vars.innodb_buffer_pool_pages_made_not_young, SHOW_SIZE_T},
+ &buf_pool.stat.n_pages_not_made_young, SHOW_SIZE_T},
{"buffer_pool_pages_made_young",
- &export_vars.innodb_buffer_pool_pages_made_young, SHOW_SIZE_T},
+ &buf_pool.stat.n_pages_made_young, SHOW_SIZE_T},
{"buffer_pool_pages_misc",
&export_vars.innodb_buffer_pool_pages_misc, SHOW_SIZE_T},
- {"buffer_pool_pages_old",
- &export_vars.innodb_buffer_pool_pages_old, SHOW_SIZE_T},
+ {"buffer_pool_pages_old", &buf_pool.LRU_old_len, SHOW_SIZE_T},
{"buffer_pool_pages_total",
&export_vars.innodb_buffer_pool_pages_total, SHOW_SIZE_T},
{"buffer_pool_pages_LRU_flushed", &buf_lru_flush_page_count, SHOW_SIZE_T},
{"buffer_pool_pages_LRU_freed", &buf_lru_freed_page_count, SHOW_SIZE_T},
+ {"buffer_pool_pages_split", &buf_pool.pages_split, SHOW_SIZE_T},
{"buffer_pool_read_ahead_rnd",
- &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_SIZE_T},
- {"buffer_pool_read_ahead",
- &export_vars.innodb_buffer_pool_read_ahead, SHOW_SIZE_T},
+ &buf_pool.stat.n_ra_pages_read_rnd, SHOW_SIZE_T},
+ {"buffer_pool_read_ahead", &buf_pool.stat.n_ra_pages_read, SHOW_SIZE_T},
{"buffer_pool_read_ahead_evicted",
- &export_vars.innodb_buffer_pool_read_ahead_evicted, SHOW_SIZE_T},
- {"buffer_pool_read_requests",
- &export_vars.innodb_buffer_pool_read_requests, SHOW_SIZE_T},
- {"buffer_pool_reads",
- &export_vars.innodb_buffer_pool_reads, SHOW_SIZE_T},
+ &buf_pool.stat.n_ra_pages_evicted, SHOW_SIZE_T},
+ {"buffer_pool_read_requests", &buf_pool.stat.n_page_gets, SHOW_SIZE_T},
+ {"buffer_pool_reads", &buf_pool.stat.n_pages_read, SHOW_SIZE_T},
{"buffer_pool_wait_free", &buf_pool.stat.LRU_waits, SHOW_SIZE_T},
{"buffer_pool_write_requests", &buf_pool.flush_list_requests, SHOW_SIZE_T},
{"checkpoint_age", &export_vars.innodb_checkpoint_age, SHOW_SIZE_T},
@@ -4500,6 +4494,25 @@ innobase_commit_ordered(
DBUG_VOID_RETURN;
}
+/** Mark the end of a statement.
+@param trx transaction
+@return whether an error occurred */
+static bool end_of_statement(trx_t *trx)
+{
+ trx_mark_sql_stat_end(trx);
+ if (UNIV_LIKELY(trx->error_state == DB_SUCCESS))
+ return false;
+
+ trx_savept_t savept;
+ savept.least_undo_no= 0;
+ trx->rollback(&savept);
+ /* MariaDB will roll back the entire transaction. */
+ trx->bulk_insert= false;
+ trx->last_sql_stat_start.least_undo_no= 0;
+ trx->savepoints_discard();
+ return true;
+}
+
/*****************************************************************//**
Commits a transaction in an InnoDB database or marks an SQL statement
ended.
@@ -4576,10 +4589,7 @@ innobase_commit(
/* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next
SQL statement */
-
- trx_mark_sql_stat_end(trx);
- if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
- trx_rollback_for_mysql(trx);
+ if (UNIV_UNLIKELY(end_of_statement(trx))) {
DBUG_RETURN(1);
}
}
@@ -15178,16 +15188,26 @@ ha_innobase::check(
}
if ((check_opt->flags & T_QUICK) || index->is_corrupted()) {
- } else if (btr_validate_index(index, m_prebuilt->trx)
- != DB_SUCCESS) {
- is_ok = false;
- push_warning_printf(thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_NOT_KEYFILE,
- "InnoDB: The B-tree of"
- " index %s is corrupted.",
- index->name());
- continue;
+ } else if (trx_id_t bulk_trx_id =
+ m_prebuilt->table->bulk_trx_id) {
+ if (!m_prebuilt->trx->read_view.changes_visible(
+ bulk_trx_id)) {
+ is_ok = true;
+ goto func_exit;
+ }
+
+ if (btr_validate_index(index, m_prebuilt->trx)
+ != DB_SUCCESS) {
+ is_ok = false;
+ push_warning_printf(
+ thd,
+ Sql_condition::WARN_LEVEL_WARN,
+ ER_NOT_KEYFILE,
+ "InnoDB: The B-tree of"
+ " index %s is corrupted.",
+ index->name());
+ continue;
+ }
}
/* Instead of invoking change_active_index(), set up
@@ -15310,6 +15330,7 @@ ha_innobase::check(
}
# endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
#endif /* BTR_CUR_HASH_ADAPT */
+func_exit:
m_prebuilt->trx->op_info = "";
DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
@@ -16975,10 +16996,7 @@ innobase_xa_prepare(
/* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next
SQL statement */
-
- trx_mark_sql_stat_end(trx);
- if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
- trx_rollback_for_mysql(trx);
+ if (UNIV_UNLIKELY(end_of_statement(trx))) {
return 1;
}
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index d6b05b3a3ec..cfa5ed922da 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -6119,6 +6119,7 @@ func_exit:
id, MTR_MEMO_PAGE_SX_FIX);
if (UNIV_UNLIKELY(!root)) {
+ err = DB_CORRUPTION;
goto func_exit;
}
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 2a26f4f5ac2..589182b73ba 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -6130,8 +6130,13 @@ static int i_s_sys_tablespaces_fill(THD *thd, const fil_space_t &s, TABLE *t)
OK(f->store(name.data(), name.size(), system_charset_info));
f->set_notnull();
}
- else
- f->set_notnull();
+ else if (srv_is_undo_tablespace(s.id))
+ {
+ char name[15];
+ snprintf(name, sizeof name, "innodb_undo%03u",
+ (s.id - srv_undo_space_id_start + 1));
+ OK(f->store(name, strlen(name), system_charset_info));
+ } else f->set_notnull();
}
fields[SYS_TABLESPACES_NAME]->set_null();
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 84ad4f3fcab..bfcc559cf5f 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -441,7 +441,7 @@ Gets the root node of a tree and x- or s-latches it.
buf_block_t*
btr_root_block_get(
/*===============*/
- const dict_index_t* index, /*!< in: index tree */
+ dict_index_t* index, /*!< in: index tree */
rw_lock_type_t mode, /*!< in: either RW_S_LATCH
or RW_X_LATCH */
mtr_t* mtr, /*!< in: mtr */
diff --git a/storage/innobase/include/btr0types.h b/storage/innobase/include/btr0types.h
index a80765e5daa..966247ffa00 100644
--- a/storage/innobase/include/btr0types.h
+++ b/storage/innobase/include/btr0types.h
@@ -87,6 +87,9 @@ enum btr_latch_mode {
dict_index_t::lock is being held in non-exclusive mode. */
BTR_MODIFY_LEAF_ALREADY_LATCHED = BTR_MODIFY_LEAF
| BTR_ALREADY_S_LATCHED,
+ /** Attempt to modify records in an x-latched tree. */
+ BTR_MODIFY_TREE_ALREADY_LATCHED = BTR_MODIFY_TREE
+ | BTR_ALREADY_S_LATCHED,
/** U-latch root and X-latch a leaf page, assuming that
dict_index_t::lock is being held in U mode. */
BTR_MODIFY_ROOT_AND_LEAF_ALREADY_LATCHED = BTR_MODIFY_ROOT_AND_LEAF
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 59aa1ac08ad..420d4a388e8 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -691,13 +691,14 @@ public:
ut_ad(s < prev_state + UNFIXED);
}
- void read_unfix(uint32_t s)
+ uint32_t read_unfix(uint32_t s)
{
ut_ad(lock.is_write_locked());
ut_ad(s == UNFIXED + 1 || s == REINIT + 1);
- ut_d(auto old_state=) zip.fix.fetch_add(s - READ_FIX);
+ uint32_t old_state= zip.fix.fetch_add(s - READ_FIX);
ut_ad(old_state >= READ_FIX);
ut_ad(old_state < WRITE_FIX);
+ return old_state + (s - READ_FIX);
}
void set_freed(uint32_t prev_state, uint32_t count= 0)
@@ -748,11 +749,11 @@ public:
it from buf_pool.flush_list */
inline void write_complete(bool temporary);
- /** Write a flushable page to a file. buf_pool.mutex must be held.
- @param lru true=buf_pool.LRU; false=buf_pool.flush_list
+ /** Write a flushable page to a file or free a freeable block.
+ @param evict whether to evict the page on write completion
@param space tablespace
- @return whether the page was flushed and buf_pool.mutex was released */
- inline bool flush(bool lru, fil_space_t *space);
+ @return whether a page write was initiated and buf_pool.mutex released */
+ bool flush(bool evict, fil_space_t *space);
/** Notify that a page in a temporary tablespace has been modified. */
void set_temp_modified()
@@ -822,8 +823,6 @@ public:
/** @return whether the block is mapped to a data file */
bool in_file() const { return state() >= FREED; }
- /** @return whether the block is modified and ready for flushing */
- inline bool ready_for_flush() const;
/** @return whether the block can be relocated in memory.
The block can be dirty, but it must not be I/O-fixed or bufferfixed. */
inline bool can_relocate() const;
@@ -996,10 +995,10 @@ Compute the hash fold value for blocks in buf_pool.zip_hash. */
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
/* @} */
-/** A "Hazard Pointer" class used to iterate over page lists
-inside the buffer pool. A hazard pointer is a buf_page_t pointer
+/** A "Hazard Pointer" class used to iterate over buf_pool.LRU or
+buf_pool.flush_list. A hazard pointer is a buf_page_t pointer
which we intend to iterate over next and we want it remain valid
-even after we release the buffer pool mutex. */
+even after we release the mutex that protects the list. */
class HazardPointer
{
public:
@@ -1114,7 +1113,8 @@ struct buf_buddy_free_t {
/*!< Node of zip_free list */
};
-/** @brief The buffer pool statistics structure. */
+/** @brief The buffer pool statistics structure;
+protected by buf_pool.mutex unless otherwise noted. */
struct buf_pool_stat_t{
/** Initialize the counters */
void init() { memset((void*) this, 0, sizeof *this); }
@@ -1123,9 +1123,8 @@ struct buf_pool_stat_t{
/*!< number of page gets performed;
also successful searches through
the adaptive hash index are
- counted as page gets; this field
- is NOT protected by the buffer
- pool mutex */
+ counted as page gets;
+ NOT protected by buf_pool.mutex */
ulint n_pages_read; /*!< number read operations */
ulint n_pages_written;/*!< number write operations */
ulint n_pages_created;/*!< number of pages created
@@ -1143,10 +1142,9 @@ struct buf_pool_stat_t{
young because the first access
was not long enough ago, in
buf_page_peek_if_too_old() */
- /** number of waits for eviction; writes protected by buf_pool.mutex */
+ /** number of waits for eviction */
ulint LRU_waits;
ulint LRU_bytes; /*!< LRU size in bytes */
- ulint flush_list_bytes;/*!< flush_list size in bytes */
};
/** Statistics of buddy blocks of a given size. */
@@ -1399,6 +1397,11 @@ public:
n_chunks_new / 4 * chunks->size;
}
+ /** @return whether the buffer pool has run out */
+ TPOOL_SUPPRESS_TSAN
+ bool ran_out() const
+ { return UNIV_UNLIKELY(!try_LRU_scan || !UT_LIST_GET_LEN(free)); }
+
/** @return whether the buffer pool is shrinking */
inline bool is_shrinking() const
{
@@ -1436,17 +1439,10 @@ public:
/** Buffer pool mutex */
alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex;
- /** Number of pending LRU flush; protected by mutex. */
- ulint n_flush_LRU_;
- /** broadcast when n_flush_LRU reaches 0; protected by mutex */
- pthread_cond_t done_flush_LRU;
- /** Number of pending flush_list flush; protected by mutex */
- ulint n_flush_list_;
- /** broadcast when n_flush_list reaches 0; protected by mutex */
- pthread_cond_t done_flush_list;
-
- TPOOL_SUPPRESS_TSAN ulint n_flush_LRU() const { return n_flush_LRU_; }
- TPOOL_SUPPRESS_TSAN ulint n_flush_list() const { return n_flush_list_; }
+ /** current statistics; protected by mutex */
+ buf_pool_stat_t stat;
+ /** old statistics; protected by mutex */
+ buf_pool_stat_t old_stat;
/** @name General fields */
/* @{ */
@@ -1607,11 +1603,12 @@ public:
buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX + 1];
/*!< Statistics of buddy system,
indexed by block size */
- buf_pool_stat_t stat; /*!< current statistics */
- buf_pool_stat_t old_stat; /*!< old statistics */
/* @} */
+ /** number of index page splits */
+ Atomic_counter<ulint> pages_split;
+
/** @name Page flushing algorithm fields */
/* @{ */
@@ -1620,7 +1617,10 @@ public:
alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_list_mutex;
/** "hazard pointer" for flush_list scans; protected by flush_list_mutex */
FlushHp flush_hp;
- /** modified blocks (a subset of LRU) */
+ /** flush_list size in bytes; protected by flush_list_mutex */
+ ulint flush_list_bytes;
+ /** possibly modified persistent pages (a subset of LRU);
+ buf_dblwr.pending_writes() is approximately COUNT(is_write_fixed()) */
UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
/** number of blocks ever added to flush_list;
sometimes protected by flush_list_mutex */
@@ -1629,28 +1629,70 @@ public:
TPOOL_SUPPRESS_TSAN void add_flush_list_requests(size_t size)
{ ut_ad(size); flush_list_requests+= size; }
private:
- /** whether the page cleaner needs wakeup from indefinite sleep */
- bool page_cleaner_is_idle;
+ static constexpr unsigned PAGE_CLEANER_IDLE= 1;
+ static constexpr unsigned FLUSH_LIST_ACTIVE= 2;
+ static constexpr unsigned LRU_FLUSH= 4;
+
+ /** Number of pending LRU flush * LRU_FLUSH +
+ PAGE_CLEANER_IDLE + FLUSH_LIST_ACTIVE flags */
+ unsigned page_cleaner_status;
/** track server activity count for signaling idle flushing */
ulint last_activity_count;
public:
/** signalled to wake up the page_cleaner; protected by flush_list_mutex */
pthread_cond_t do_flush_list;
+ /** broadcast when !n_flush(); protected by flush_list_mutex */
+ pthread_cond_t done_flush_LRU;
+ /** broadcast when a batch completes; protected by flush_list_mutex */
+ pthread_cond_t done_flush_list;
+
+ /** @return number of pending LRU flush */
+ unsigned n_flush() const
+ {
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ return page_cleaner_status / LRU_FLUSH;
+ }
+
+ /** Increment the number of pending LRU flush */
+ inline void n_flush_inc();
+
+ /** Decrement the number of pending LRU flush */
+ inline void n_flush_dec();
+
+ /** @return whether flush_list flushing is active */
+ bool flush_list_active() const
+ {
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ return page_cleaner_status & FLUSH_LIST_ACTIVE;
+ }
+
+ void flush_list_set_active()
+ {
+ ut_ad(!flush_list_active());
+ page_cleaner_status+= FLUSH_LIST_ACTIVE;
+ }
+ void flush_list_set_inactive()
+ {
+ ut_ad(flush_list_active());
+ page_cleaner_status-= FLUSH_LIST_ACTIVE;
+ }
/** @return whether the page cleaner must sleep due to being idle */
bool page_cleaner_idle() const noexcept
{
mysql_mutex_assert_owner(&flush_list_mutex);
- return page_cleaner_is_idle;
+ return page_cleaner_status & PAGE_CLEANER_IDLE;
}
- /** Wake up the page cleaner if needed */
- void page_cleaner_wakeup();
+ /** Wake up the page cleaner if needed.
+ @param for_LRU whether to wake up for LRU eviction */
+ void page_cleaner_wakeup(bool for_LRU= false);
/** Register whether an explicit wakeup of the page cleaner is needed */
void page_cleaner_set_idle(bool deep_sleep)
{
mysql_mutex_assert_owner(&flush_list_mutex);
- page_cleaner_is_idle= deep_sleep;
+ page_cleaner_status= (page_cleaner_status & ~PAGE_CLEANER_IDLE) |
+ (PAGE_CLEANER_IDLE * deep_sleep);
}
/** Update server last activity count */
@@ -1660,9 +1702,6 @@ public:
last_activity_count= activity_count;
}
- // n_flush_LRU() + n_flush_list()
- // is approximately COUNT(is_write_fixed()) in flush_list
-
unsigned freed_page_clock;/*!< a sequence number used
to count the number of buffer
blocks removed from the end of
@@ -1672,16 +1711,10 @@ public:
to read this for heuristic
purposes without holding any
mutex or latch */
- bool try_LRU_scan; /*!< Cleared when an LRU
- scan for free block fails. This
- flag is used to avoid repeated
- scans of LRU list when we know
- that there is no free block
- available in the scan depth for
- eviction. Set whenever
- we flush a batch from the
- buffer pool. Protected by the
- buf_pool.mutex */
+ /** Cleared when buf_LRU_get_free_block() fails.
+ Set whenever the free list grows, along with a broadcast of done_free.
+ Protected by buf_pool.mutex. */
+ Atomic_relaxed<bool> try_LRU_scan;
/* @} */
/** @name LRU replacement algorithm fields */
@@ -1690,7 +1723,8 @@ public:
UT_LIST_BASE_NODE_T(buf_page_t) free;
/*!< base node of the free
block list */
- /** signaled each time when the free list grows; protected by mutex */
+ /** broadcast each time when the free list grows or try_LRU_scan is set;
+ protected by mutex */
pthread_cond_t done_free;
UT_LIST_BASE_NODE_T(buf_page_t) withdraw;
@@ -1747,29 +1781,16 @@ public:
{
if (n_pend_reads)
return true;
- mysql_mutex_lock(&mutex);
- const bool any_pending{n_flush_LRU_ || n_flush_list_};
- mysql_mutex_unlock(&mutex);
+ mysql_mutex_lock(&flush_list_mutex);
+ const bool any_pending= page_cleaner_status > PAGE_CLEANER_IDLE ||
+ buf_dblwr.pending_writes();
+ mysql_mutex_unlock(&flush_list_mutex);
return any_pending;
}
- /** @return total amount of pending I/O */
- ulint io_pending() const
- {
- return n_pend_reads + n_flush_LRU() + n_flush_list();
- }
-private:
- /** Remove a block from the flush list. */
- inline void delete_from_flush_list_low(buf_page_t *bpage) noexcept;
- /** Remove a block from flush_list.
- @param bpage buffer pool page
- @param clear whether to invoke buf_page_t::clear_oldest_modification() */
- void delete_from_flush_list(buf_page_t *bpage, bool clear) noexcept;
-public:
/** Remove a block from flush_list.
@param bpage buffer pool page */
- void delete_from_flush_list(buf_page_t *bpage) noexcept
- { delete_from_flush_list(bpage, true); }
+ void delete_from_flush_list(buf_page_t *bpage) noexcept;
/** Prepare to insert a modified blcok into flush_list.
@param lsn start LSN of the mini-transaction
@@ -1784,7 +1805,7 @@ public:
lsn_t lsn) noexcept;
/** Free a page whose underlying file page has been freed. */
- inline void release_freed_page(buf_page_t *bpage) noexcept;
+ ATTRIBUTE_COLD void release_freed_page(buf_page_t *bpage) noexcept;
private:
/** Temporary memory for page_compressed and encrypted I/O */
@@ -1795,34 +1816,12 @@ private:
/** array of slots */
buf_tmp_buffer_t *slots;
- void create(ulint n_slots)
- {
- this->n_slots= n_slots;
- slots= static_cast<buf_tmp_buffer_t*>
- (ut_malloc_nokey(n_slots * sizeof *slots));
- memset((void*) slots, 0, n_slots * sizeof *slots);
- }
+ void create(ulint n_slots);
- void close()
- {
- for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
- {
- aligned_free(s->crypt_buf);
- aligned_free(s->comp_buf);
- }
- ut_free(slots);
- slots= nullptr;
- n_slots= 0;
- }
+ void close();
/** Reserve a buffer */
- buf_tmp_buffer_t *reserve()
- {
- for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
- if (s->acquire())
- return s;
- return nullptr;
- }
+ buf_tmp_buffer_t *reserve();
} io_buf;
/** whether resize() is in the critical path */
@@ -1911,7 +1910,10 @@ inline void buf_page_t::set_oldest_modification(lsn_t lsn)
/** Clear oldest_modification after removing from buf_pool.flush_list */
inline void buf_page_t::clear_oldest_modification()
{
- mysql_mutex_assert_owner(&buf_pool.flush_list_mutex);
+#ifdef SAFE_MUTEX
+ if (oldest_modification() != 2)
+ mysql_mutex_assert_owner(&buf_pool.flush_list_mutex);
+#endif /* SAFE_MUTEX */
ut_d(const auto s= state());
ut_ad(s >= REMOVE_HASH);
ut_ad(oldest_modification());
@@ -1923,17 +1925,6 @@ inline void buf_page_t::clear_oldest_modification()
oldest_modification_.store(0, std::memory_order_release);
}
-/** @return whether the block is modified and ready for flushing */
-inline bool buf_page_t::ready_for_flush() const
-{
- mysql_mutex_assert_owner(&buf_pool.mutex);
- ut_ad(in_LRU_list);
- const auto s= state();
- ut_a(s >= FREED);
- ut_ad(!fsp_is_system_temporary(id().space()) || oldest_modification() == 2);
- return s < READ_FIX;
-}
-
/** @return whether the block can be relocated in memory.
The block can be dirty, but it must not be I/O-fixed or bufferfixed. */
inline bool buf_page_t::can_relocate() const
diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h
index fb9df55504c..d9c9239c0b4 100644
--- a/storage/innobase/include/buf0dblwr.h
+++ b/storage/innobase/include/buf0dblwr.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -54,9 +54,9 @@ class buf_dblwr_t
};
/** the page number of the first doublewrite block (block_size() pages) */
- page_id_t block1= page_id_t(0, 0);
+ page_id_t block1{0, 0};
/** the page number of the second doublewrite block (block_size() pages) */
- page_id_t block2= page_id_t(0, 0);
+ page_id_t block2{0, 0};
/** mutex protecting the data members below */
mysql_mutex_t mutex;
@@ -72,11 +72,15 @@ class buf_dblwr_t
ulint writes_completed;
/** number of pages written by flush_buffered_writes_completed() */
ulint pages_written;
+ /** condition variable for !writes_pending */
+ pthread_cond_t write_cond;
+ /** number of pending page writes */
+ size_t writes_pending;
slot slots[2];
- slot *active_slot= &slots[0];
+ slot *active_slot;
- /** Initialize the doublewrite buffer data structure.
+ /** Initialise the persistent storage of the doublewrite buffer.
@param header doublewrite page header in the TRX_SYS page */
inline void init(const byte *header);
@@ -84,6 +88,8 @@ class buf_dblwr_t
bool flush_buffered_writes(const ulint size);
public:
+ /** Initialise the doublewrite buffer data structures. */
+ void init();
/** Create or restore the doublewrite buffer in the TRX_SYS page.
@return whether the operation succeeded */
bool create();
@@ -118,7 +124,7 @@ public:
void recover();
/** Update the doublewrite buffer on data page write completion. */
- void write_completed();
+ void write_completed(bool with_doublewrite);
/** Flush possible buffered writes to persistent storage.
It is very important to call this function after a batch of writes has been
posted, and also when we may have to wait for a page latch!
@@ -137,14 +143,14 @@ public:
@param size payload size in bytes */
void add_to_batch(const IORequest &request, size_t size);
- /** Determine whether the doublewrite buffer is initialized */
- bool is_initialised() const
+ /** Determine whether the doublewrite buffer has been created */
+ bool is_created() const
{ return UNIV_LIKELY(block1 != page_id_t(0, 0)); }
/** @return whether a page identifier is part of the doublewrite buffer */
bool is_inside(const page_id_t id) const
{
- if (!is_initialised())
+ if (!is_created())
return false;
ut_ad(block1 < block2);
if (id < block1)
@@ -156,13 +162,44 @@ public:
/** Wait for flush_buffered_writes() to be fully completed */
void wait_flush_buffered_writes()
{
- if (is_initialised())
- {
- mysql_mutex_lock(&mutex);
- while (batch_running)
- my_cond_wait(&cond, &mutex.m_mutex);
- mysql_mutex_unlock(&mutex);
- }
+ mysql_mutex_lock(&mutex);
+ while (batch_running)
+ my_cond_wait(&cond, &mutex.m_mutex);
+ mysql_mutex_unlock(&mutex);
+ }
+
+ /** Register an unbuffered page write */
+ void add_unbuffered()
+ {
+ mysql_mutex_lock(&mutex);
+ writes_pending++;
+ mysql_mutex_unlock(&mutex);
+ }
+
+ size_t pending_writes()
+ {
+ mysql_mutex_lock(&mutex);
+ const size_t pending{writes_pending};
+ mysql_mutex_unlock(&mutex);
+ return pending;
+ }
+
+ /** Wait for writes_pending to reach 0 */
+ void wait_for_page_writes()
+ {
+ mysql_mutex_lock(&mutex);
+ while (writes_pending)
+ my_cond_wait(&write_cond, &mutex.m_mutex);
+ mysql_mutex_unlock(&mutex);
+ }
+
+ /** Wait for writes_pending to reach 0 */
+ void wait_for_page_writes(const timespec &abstime)
+ {
+ mysql_mutex_lock(&mutex);
+ while (writes_pending)
+ my_cond_timedwait(&write_cond, &mutex.m_mutex, &abstime);
+ mysql_mutex_unlock(&mutex);
}
};
diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h
index af38f61b13b..31fe4446681 100644
--- a/storage/innobase/include/buf0flu.h
+++ b/storage/innobase/include/buf0flu.h
@@ -30,10 +30,8 @@ Created 11/5/1995 Heikki Tuuri
#include "log0log.h"
#include "buf0buf.h"
-/** Number of pages flushed. Protected by buf_pool.mutex. */
-extern ulint buf_flush_page_count;
/** Number of pages flushed via LRU. Protected by buf_pool.mutex.
-Also included in buf_flush_page_count. */
+Also included in buf_pool.stat.n_pages_written. */
extern ulint buf_lru_flush_page_count;
/** Number of pages freed without flushing. Protected by buf_pool.mutex. */
extern ulint buf_lru_freed_page_count;
@@ -86,15 +84,18 @@ buf_flush_init_for_writing(
bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed= nullptr)
MY_ATTRIBUTE((warn_unused_result));
-/** Write out dirty blocks from buf_pool.LRU.
+/** Write out dirty blocks from buf_pool.LRU,
+and move clean blocks to buf_pool.free.
+The caller must invoke buf_dblwr.flush_buffered_writes()
+after releasing buf_pool.mutex.
@param max_n wished maximum mumber of blocks flushed
-@return the number of processed pages
+@param evict whether to evict pages after flushing
+@return evict ? number of processed pages : number of pages written
@retval 0 if a buf_pool.LRU batch is already running */
-ulint buf_flush_LRU(ulint max_n);
+ulint buf_flush_LRU(ulint max_n, bool evict);
-/** Wait until a flush batch ends.
-@param lru true=buf_pool.LRU; false=buf_pool.flush_list */
-void buf_flush_wait_batch_end(bool lru);
+/** Wait until a LRU flush batch ends. */
+void buf_flush_wait_LRU_batch_end();
/** Wait until all persistent pages are flushed up to a limit.
@param sync_lsn buf_pool.get_oldest_modification(LSN_MAX) to wait for */
ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn);
@@ -106,9 +107,6 @@ ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious);
/** Initialize page_cleaner. */
ATTRIBUTE_COLD void buf_flush_page_cleaner_init();
-/** Wait for pending flushes to complete. */
-void buf_flush_wait_batch_end_acquiring_mutex(bool lru);
-
/** Flush the buffer pool on shutdown. */
ATTRIBUTE_COLD void buf_flush_buffer_pool();
diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h
index 65ae33cc188..ebf0f60ffe5 100644
--- a/storage/innobase/include/buf0rea.h
+++ b/storage/innobase/include/buf0rea.h
@@ -36,6 +36,7 @@ released by the i/o-handler thread.
@param zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param chain buf_pool.page_hash cell for page_id
@retval DB_SUCCESS if the page was read and is not corrupted,
+@retval DB_SUCCESS_LOCKED_REC if the page was not read
@retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted,
@retval DB_DECRYPTION_FAILED if page post encryption checksum matches but
after decryption normal page checksum does not match.
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 65ca704b6d8..f53279ecb88 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -871,11 +871,13 @@ public:
@param purpose tablespace purpose
@param crypt_data encryption information
@param mode encryption mode
+ @param opened true if space files are opened
@return pointer to created tablespace, to be filled in with add()
@retval nullptr on failure (such as when the same tablespace exists) */
static fil_space_t *create(uint32_t id, uint32_t flags,
fil_type_t purpose, fil_space_crypt_t *crypt_data,
- fil_encryption_t mode= FIL_ENCRYPTION_DEFAULT);
+ fil_encryption_t mode= FIL_ENCRYPTION_DEFAULT,
+ bool opened= false);
MY_ATTRIBUTE((warn_unused_result))
/** Acquire a tablespace reference.
@@ -1080,7 +1082,7 @@ private:
inline bool fil_space_t::use_doublewrite() const
{
return !UT_LIST_GET_FIRST(chain)->atomic_write && srv_use_doublewrite_buf &&
- buf_dblwr.is_initialised();
+ buf_dblwr.is_created();
}
inline void fil_space_t::set_imported()
@@ -1357,6 +1359,11 @@ struct fil_system_t
private:
bool m_initialised;
+
+ /** Points to the last opened space in space_list. Protected with
+ fil_system.mutex. */
+ fil_space_t *space_list_last_opened= nullptr;
+
#ifdef __linux__
/** available block devices that reside on non-rotational storage */
std::vector<dev_t> ssd;
@@ -1412,7 +1419,8 @@ public:
/** nonzero if fil_node_open_file_low() should avoid moving the tablespace
to the end of space_list, for FIFO policy of try_to_close() */
ulint freeze_space_list;
- /** list of all tablespaces */
+ /** List of all file spaces, opened spaces should be at the top of the list
+ to optimize try_to_close() execution. Protected with fil_system.mutex. */
ilist<fil_space_t, space_list_tag_t> space_list;
/** list of all tablespaces for which a FILE_MODIFY record has been written
since the latest redo log checkpoint.
@@ -1427,6 +1435,49 @@ public:
potential space_id reuse */
bool space_id_reuse_warned;
+ /** Add the file to the end of opened spaces list in
+ fil_system.space_list, so that fil_space_t::try_to_close() should close
+ it as a last resort.
+ @param space space to add */
+ void add_opened_last_to_space_list(fil_space_t *space);
+
+ /** Move the file to the end of opened spaces list in
+ fil_system.space_list, so that fil_space_t::try_to_close() should close
+ it as a last resort.
+ @param space space to move */
+ inline void move_opened_last_to_space_list(fil_space_t *space)
+ {
+ /* In the case when several files of the same space are added in a
+ row, there is no need to remove and add a space to the same position
+ in space_list. It can be for system or temporary tablespaces. */
+ if (freeze_space_list || space_list_last_opened == space)
+ return;
+
+ space_list.erase(space_list_t::iterator(space));
+ add_opened_last_to_space_list(space);
+ }
+
+ /** Move closed file last in fil_system.space_list, so that
+ fil_space_t::try_to_close() iterates opened files first in FIFO order,
+ i.e. first opened, first closed.
+ @param space space to move */
+ void move_closed_last_to_space_list(fil_space_t *space)
+ {
+ if (UNIV_UNLIKELY(freeze_space_list))
+ return;
+
+ space_list_t::iterator s= space_list_t::iterator(space);
+
+ if (space_list_last_opened == space)
+ {
+ space_list_t::iterator prev= s;
+ space_list_last_opened= &*--prev;
+ }
+
+ space_list.erase(s);
+ space_list.push_back(*space);
+ }
+
/** Return the next tablespace from default_encrypt_tables list.
@param space previous tablespace (nullptr to start from the start)
@param recheck whether the removal condition needs to be rechecked after
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index cdb159a5b26..5576560dca8 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -333,6 +333,9 @@ public:
/** Upgrade U locks on a block to X */
void page_lock_upgrade(const buf_block_t &block);
+ /** Upgrade index U lock to X */
+ ATTRIBUTE_COLD void index_lock_upgrade();
+
/** Check if we are holding tablespace latch
@param space tablespace to search for
@return whether space.latch is being held */
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index e2fb6bad6d7..0c6aa8a94bb 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -85,11 +85,6 @@ struct srv_stats_t
/** Count the amount of data written in total (in bytes) */
ulint_ctr_1_t data_written;
-
- /** Number of buffer pool reads that led to the reading of
- a disk page */
- ulint_ctr_1_t buf_pool_reads;
-
/** Number of bytes saved by page compression */
ulint_ctr_n_t page_compression_saved;
/* Number of pages compressed with page compression */
@@ -597,23 +592,11 @@ struct export_var_t{
char innodb_buffer_pool_resize_status[512];/*!< Buf pool resize status */
my_bool innodb_buffer_pool_load_incomplete;/*!< Buf pool load incomplete */
ulint innodb_buffer_pool_pages_total; /*!< Buffer pool size */
- ulint innodb_buffer_pool_pages_data; /*!< Data pages */
ulint innodb_buffer_pool_bytes_data; /*!< File bytes used */
- ulint innodb_buffer_pool_pages_dirty; /*!< Dirty data pages */
- ulint innodb_buffer_pool_bytes_dirty; /*!< File bytes modified */
ulint innodb_buffer_pool_pages_misc; /*!< Miscellanous pages */
- ulint innodb_buffer_pool_pages_free; /*!< Free pages */
#ifdef UNIV_DEBUG
ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
#endif /* UNIV_DEBUG */
- ulint innodb_buffer_pool_pages_made_not_young;
- ulint innodb_buffer_pool_pages_made_young;
- ulint innodb_buffer_pool_pages_old;
- ulint innodb_buffer_pool_read_requests; /*!< buf_pool.stat.n_page_gets */
- ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
- ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
- ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
- ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
ulint innodb_checkpoint_age;
ulint innodb_checkpoint_max_age;
ulint innodb_data_pending_reads; /*!< Pending reads */
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
index 03af55aadf5..d0f5e9ad1b4 100644
--- a/storage/innobase/include/trx0sys.h
+++ b/storage/innobase/include/trx0sys.h
@@ -925,14 +925,19 @@ public:
/**
Determine if the specified transaction or any older one might be active.
- @param caller_trx used to get/set pins
+ @param trx current transaction
@param id transaction identifier
@return whether any transaction not newer than id might be active
*/
- bool find_same_or_older(trx_t *caller_trx, trx_id_t id)
+ bool find_same_or_older(trx_t *trx, trx_id_t id)
{
- return rw_trx_hash.iterate(caller_trx, find_same_or_older_callback, &id);
+ if (trx->max_inactive_id >= id)
+ return false;
+ bool found= rw_trx_hash.iterate(trx, find_same_or_older_callback, &id);
+ if (!found)
+ trx->max_inactive_id= id;
+ return found;
}
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 2799750ee01..81eb5471a7b 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -642,6 +642,10 @@ public:
Cleared in commit_in_memory() after commit_state(),
trx_sys_t::deregister_rw(), release_locks(). */
trx_id_t id;
+ /** The largest encountered transaction identifier for which no
+ transaction was observed to be active. This is a cache to speed up
+ trx_sys_t::find_same_or_older(). */
+ trx_id_t max_inactive_id;
private:
/** mutex protecting state and some of lock
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 0aeb6fd1b30..b56098f5e9d 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1064,13 +1064,16 @@ lock_sec_rec_some_has_impl(
const trx_id_t max_trx_id= page_get_max_trx_id(page_align(rec));
- if ((caller_trx->id > max_trx_id &&
- !trx_sys.find_same_or_older(caller_trx, max_trx_id)) ||
+ /* Note: It is possible to have caller_trx->id == 0 in a locking read
+ if caller_trx has not modified any persistent tables. */
+ if (!trx_sys.find_same_or_older(caller_trx, max_trx_id) ||
!lock_check_trx_id_sanity(max_trx_id, rec, index, offsets))
return nullptr;
- /* In this case it is possible that some transaction has an implicit
- x-lock. We have to look in the clustered index. */
+ /* We checked above that some active (or XA PREPARE) transaction exists
+ that is older than PAGE_MAX_TRX_ID. That is, some transaction may be
+ holding an implicit lock on the record. We have to look up the
+ clustered index record to find if it is (or was) the case. */
return row_vers_impl_x_locked(caller_trx, rec, index, offsets);
}
@@ -5157,20 +5160,24 @@ has an implicit lock on the record. The transaction instance must have a
reference count > 0 so that it can't be committed and freed before this
function has completed. */
static
-void
+bool
lock_rec_convert_impl_to_expl_for_trx(
/*==================================*/
+ trx_t* trx, /*!< in/out: active transaction */
const page_id_t id, /*!< in: page identifier */
const rec_t* rec, /*!< in: user record on page */
- dict_index_t* index, /*!< in: index of record */
- trx_t* trx, /*!< in/out: active transaction */
- ulint heap_no)/*!< in: rec heap number to lock */
+ dict_index_t* index) /*!< in: index of record */
{
+ if (!trx)
+ return false;
+
ut_ad(trx->is_referenced());
ut_ad(page_rec_is_leaf(rec));
ut_ad(!rec_is_metadata(rec, *index));
DEBUG_SYNC_C("before_lock_rec_convert_impl_to_expl_for_trx");
+ ulint heap_no= page_rec_get_heap_no(rec);
+
{
LockGuard g{lock_sys.rec_hash, id};
trx->mutex_lock();
@@ -5187,6 +5194,7 @@ lock_rec_convert_impl_to_expl_for_trx(
trx->release_reference();
DEBUG_SYNC_C("after_lock_rec_convert_impl_to_expl_for_trx");
+ return false;
}
@@ -5260,7 +5268,6 @@ static void lock_rec_other_trx_holds_expl(trx_t *caller_trx, trx_t *trx,
}
#endif /* UNIV_DEBUG */
-
/** If an implicit x-lock exists on a record, convert it to an explicit one.
Often, this is called by a transaction that is about to enter a lock wait
@@ -5272,12 +5279,14 @@ This may also be called by the same transaction that is already holding
an implicit exclusive lock on the record. In this case, no explicit lock
should be created.
+@tparam is_primary whether the index is the primary key
@param[in,out] caller_trx current transaction
@param[in] id index tree leaf page identifier
@param[in] rec record on the leaf page
@param[in] index the index of the record
@param[in] offsets rec_get_offsets(rec,index)
@return whether caller_trx already holds an exclusive lock on rec */
+template<bool is_primary>
static
bool
lock_rec_convert_impl_to_expl(
@@ -5295,8 +5304,9 @@ lock_rec_convert_impl_to_expl(
ut_ad(!page_rec_is_comp(rec) == !rec_offs_comp(offsets));
ut_ad(page_rec_is_leaf(rec));
ut_ad(!rec_is_metadata(rec, *index));
+ ut_ad(index->is_primary() == is_primary);
- if (dict_index_is_clust(index)) {
+ if (is_primary) {
trx_id_t trx_id;
trx_id = lock_clust_rec_some_has_impl(rec, index, offsets);
@@ -5322,20 +5332,7 @@ lock_rec_convert_impl_to_expl(
ut_d(lock_rec_other_trx_holds_expl(caller_trx, trx, rec, id));
}
- if (trx) {
- ulint heap_no = page_rec_get_heap_no(rec);
-
- ut_ad(trx->is_referenced());
-
- /* If the transaction is still active and has no
- explicit x-lock set on the record, set one for it.
- trx cannot be committed until the ref count is zero. */
-
- lock_rec_convert_impl_to_expl_for_trx(
- id, rec, index, trx, heap_no);
- }
-
- return false;
+ return lock_rec_convert_impl_to_expl_for_trx(trx, id, rec, index);
}
/*********************************************************************//**
@@ -5374,8 +5371,9 @@ lock_clust_rec_modify_check_and_lock(
/* If a transaction has no explicit x-lock set on the record, set one
for it */
- if (lock_rec_convert_impl_to_expl(thr_get_trx(thr), block->page.id(),
- rec, index, offsets)) {
+ if (lock_rec_convert_impl_to_expl<true>(thr_get_trx(thr),
+ block->page.id(),
+ rec, index, offsets)) {
/* We already hold an implicit exclusive lock. */
return DB_SUCCESS;
}
@@ -5532,15 +5530,17 @@ lock_sec_rec_read_check_and_lock(
return(DB_SUCCESS);
}
- const page_id_t id{block->page.id()};
-
ut_ad(!rec_is_metadata(rec, *index));
trx_t *trx = thr_get_trx(thr);
+
+ if (lock_table_has(trx, index->table, mode)) {
+ return DB_SUCCESS;
+ }
+
if (!page_rec_is_supremum(rec)
- && !lock_table_has(trx, index->table, LOCK_X)
- && lock_rec_convert_impl_to_expl(thr_get_trx(thr), id, rec,
- index, offsets)
+ && lock_rec_convert_impl_to_expl<false>(
+ trx, block->page.id(), rec, index, offsets)
&& gap_mode == LOCK_REC_NOT_GAP) {
/* We already hold an implicit exclusive lock. */
return DB_SUCCESS;
@@ -5565,7 +5565,8 @@ lock_sec_rec_read_check_and_lock(
if (trx->wsrep == 3) trx->wsrep = 1;
#endif /* WITH_WSREP */
- ut_ad(lock_rec_queue_validate(false, id, rec, index, offsets));
+ ut_ad(lock_rec_queue_validate(false, block->page.id(),
+ rec, index, offsets));
return(err);
}
@@ -5622,7 +5623,8 @@ lock_clust_rec_read_check_and_lock(
trx_t *trx = thr_get_trx(thr);
if (!lock_table_has(trx, index->table, LOCK_X)
&& heap_no != PAGE_HEAP_NO_SUPREMUM
- && lock_rec_convert_impl_to_expl(trx, id, rec, index, offsets)
+ && lock_rec_convert_impl_to_expl<true>(trx, id,
+ rec, index, offsets)
&& gap_mode == LOCK_REC_NOT_GAP) {
/* We already hold an implicit exclusive lock. */
return DB_SUCCESS;
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index 49432a8b8e3..209e1e60e2a 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -1160,14 +1160,6 @@ wait_suspend_loop:
if (!buf_pool.is_initialised()) {
ut_ad(!srv_was_started);
- } else if (ulint pending_io = buf_pool.io_pending()) {
- if (srv_print_verbose_log && count > 600) {
- ib::info() << "Waiting for " << pending_io << " buffer"
- " page I/Os to complete";
- count = 0;
- }
-
- goto loop;
} else {
buf_flush_buffer_pool();
}
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 54e2e1a42f4..3443369af6c 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -3004,7 +3004,7 @@ set_start_lsn:
/* The following is adapted from
buf_pool_t::insert_into_flush_list() */
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- buf_pool.stat.flush_list_bytes+= block->physical_size();
+ buf_pool.flush_list_bytes+= block->physical_size();
block->page.set_oldest_modification(start_lsn);
UT_LIST_ADD_FIRST(buf_pool.flush_list, &block->page);
buf_pool.page_cleaner_wakeup();
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index d642c7266bb..6d31a55e8ed 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -140,9 +140,9 @@ inline void buf_pool_t::insert_into_flush_list(buf_page_t *prev,
UT_LIST_REMOVE(flush_list, &block->page);
}
else
- stat.flush_list_bytes+= block->physical_size();
+ flush_list_bytes+= block->physical_size();
- ut_ad(stat.flush_list_bytes <= curr_pool_size);
+ ut_ad(flush_list_bytes <= curr_pool_size);
if (prev)
UT_LIST_INSERT_AFTER(flush_list, prev, &block->page);
diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc
index a84cba01ef0..f489669b408 100644
--- a/storage/innobase/rem/rem0rec.cc
+++ b/storage/innobase/rem/rem0rec.cc
@@ -217,14 +217,12 @@ rec_get_n_extern_new(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- if (len & 0x40) {
- n_extern++;
- }
- lens--;
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ if (len & 0x40) {
+ n_extern++;
}
+ lens--;
}
}
} while (++i < n);
@@ -244,6 +242,10 @@ enum rec_leaf_format {
REC_LEAF_INSTANT
};
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 11
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 to 10 need this */
+#endif
/** Determine the offset to each field in a leaf-page record
in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED.
This is a special case of rec_init_offsets() and rec_get_offsets_func().
@@ -361,8 +363,7 @@ start:
do {
if (mblob) {
if (i == index->first_user_field()) {
- offs = static_cast<rec_offs>(offs
- + FIELD_REF_SIZE);
+ offs += FIELD_REF_SIZE;
len = combine(offs, STORED_OFFPAGE);
any |= REC_OFFS_EXTERNAL;
field--;
@@ -433,27 +434,23 @@ start:
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if ((len & 0x80) && DATA_BIG_COL(col)) {
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
/* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(len << 8
- | *lens--);
- offs = static_cast<rec_offs>(offs
- + get_value(len));
- if (UNIV_UNLIKELY(len & 0x4000)) {
- ut_ad(index->is_primary());
- any |= REC_OFFS_EXTERNAL;
- len = combine(offs, STORED_OFFPAGE);
- } else {
- len = offs;
- }
-
+ len <<= 8;
+ len |= *lens--;
+ static_assert(STORED_OFFPAGE == 0x4000, "");
+ static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
+ const rec_offs ext = len & REC_OFFS_EXTERNAL;
+ offs += get_value(len);
+ len = offs | ext;
+ any |= ext;
+ ut_ad(!ext || index->is_primary());
continue;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(offs
- + field->fixed_len);
+ len = offs += field->fixed_len;
}
} while (field++, rec_offs_base(offsets)[++i] = len,
i < rec_offs_n_fields(offsets));
@@ -679,8 +676,7 @@ rec_init_offsets(
do {
rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
- len = offs = static_cast<rec_offs>(
- offs + REC_NODE_PTR_SIZE);
+ len = offs += REC_NODE_PTR_SIZE;
goto resolved;
}
@@ -720,29 +716,25 @@ rec_init_offsets(
encoded in two bytes when it is 128 or
more, or when the field is stored
externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(
- len << 8 | *lens--);
-
- /* B-tree node pointers
- must not contain externally
- stored columns. Thus
- the "e" flag must be 0. */
- ut_a(!(len & 0x4000));
- offs = static_cast<rec_offs>(
- offs + get_value(len));
- len = offs;
-
- goto resolved;
- }
+ if (UNIV_UNLIKELY(len & 0x80)
+ && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ len <<= 8;
+ len |= *lens--;
+
+ /* B-tree node pointers
+ must not contain externally
+ stored columns. Thus
+ the "e" flag must be 0. */
+ ut_a(!(len & 0x4000));
+ offs += len & 0x3fff;
+ len = offs;
+ goto resolved;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(
- offs + field->fixed_len);
+ len = offs += field->fixed_len;
}
resolved:
rec_offs_base(offsets)[i + 1] = len;
@@ -759,35 +751,30 @@ resolved:
rec_offs any;
if (rec_get_1byte_offs_flag(rec)) {
- offs = static_cast<rec_offs>(offs + n_fields);
+ offs += static_cast<rec_offs>(n_fields);
any = offs;
/* Determine offsets to fields */
do {
offs = rec_1_get_field_end_info(rec, i);
if (offs & REC_1BYTE_SQL_NULL_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_1BYTE_SQL_NULL_MASK);
- set_type(offs, SQL_NULL);
+ offs ^= REC_1BYTE_SQL_NULL_MASK
+ | SQL_NULL;
}
rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n);
} else {
- offs = static_cast<rec_offs>(offs + 2 * n_fields);
+ offs += static_cast<rec_offs>(2 * n_fields);
any = offs;
/* Determine offsets to fields */
do {
offs = rec_2_get_field_end_info(rec, i);
- if (offs & REC_2BYTE_SQL_NULL_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_2BYTE_SQL_NULL_MASK);
- set_type(offs, SQL_NULL);
- }
- if (offs & REC_2BYTE_EXTERN_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_2BYTE_EXTERN_MASK);
- set_type(offs, STORED_OFFPAGE);
- any |= REC_OFFS_EXTERNAL;
- }
+ static_assert(REC_2BYTE_SQL_NULL_MASK
+ == SQL_NULL, "");
+ static_assert(REC_2BYTE_EXTERN_MASK
+ == STORED_OFFPAGE, "");
+ static_assert(REC_OFFS_EXTERNAL
+ == STORED_OFFPAGE, "");
+ any |= (offs & REC_OFFS_EXTERNAL);
rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n);
}
@@ -996,8 +983,7 @@ rec_get_offsets_reverse(
do {
rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
- len = offs = static_cast<rec_offs>(
- offs + REC_NODE_PTR_SIZE);
+ len = offs += REC_NODE_PTR_SIZE;
goto resolved;
}
@@ -1034,30 +1020,23 @@ rec_get_offsets_reverse(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(
- len << 8 | *lens++);
-
- offs = static_cast<rec_offs>(
- offs + get_value(len));
- if (UNIV_UNLIKELY(len & 0x4000)) {
- any_ext = REC_OFFS_EXTERNAL;
- len = combine(offs,
- STORED_OFFPAGE);
- } else {
- len = offs;
- }
-
- goto resolved;
- }
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ len &= 0x7f;
+ len <<= 8;
+ len |= *lens++;
+ static_assert(STORED_OFFPAGE == 0x4000, "");
+ static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
+ rec_offs ext = len & REC_OFFS_EXTERNAL;
+ offs += get_value(len);
+ len = offs | ext;
+ any_ext |= ext;
+ goto resolved;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(offs
- + field->fixed_len);
+ len = offs += field->fixed_len;
}
resolved:
rec_offs_base(offsets)[i + 1] = len;
@@ -1097,7 +1076,7 @@ rec_get_nth_field_offs_old(
return(os);
}
- next_os = next_os & ~REC_1BYTE_SQL_NULL_MASK;
+ next_os &= ~REC_1BYTE_SQL_NULL_MASK;
} else {
os = rec_2_get_field_start_offs(rec, n);
@@ -1109,8 +1088,7 @@ rec_get_nth_field_offs_old(
return(os);
}
- next_os = next_os & ~(REC_2BYTE_SQL_NULL_MASK
- | REC_2BYTE_EXTERN_MASK);
+ next_os &= ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK);
}
*len = next_os - os;
@@ -1263,7 +1241,8 @@ rec_get_converted_size_comp_prefix_low(
} else if (dfield_is_ext(dfield)) {
ut_ad(DATA_BIG_COL(field->col));
extra_size += 2;
- } else if (len < 128 || !DATA_BIG_COL(field->col)) {
+ } else if (UNIV_LIKELY(len < 128)
+ || !DATA_BIG_COL(field->col)) {
extra_size++;
} else {
/* For variable-length columns, we look up the
@@ -1614,14 +1593,7 @@ start:
/* set the null flag if necessary */
if (dfield_is_null(field)) {
-#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 may need this here */
-#endif
*nulls |= static_cast<byte>(null_mask);
-#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
-# pragma GCC diagnostic pop
-#endif
null_mask <<= 1;
continue;
}
@@ -1730,6 +1702,9 @@ rec_convert_dtuple_to_rec_new(
REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
return buf;
}
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 11
+# pragma GCC diagnostic pop /* ignored "-Wconversion" */
+#endif
/*********************************************************//**
Builds a physical record out of a data tuple and
@@ -2092,14 +2067,12 @@ rec_copy_prefix_to_buf(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the column is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxx */
- len &= 0x3f;
- len <<= 8;
- len |= *lens--;
- UNIV_PREFETCH_R(lens);
- }
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxx */
+ len &= 0x3f;
+ len <<= 8;
+ len |= *lens--;
+ UNIV_PREFETCH_R(lens);
}
prefix_len += len;
}
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index a20991cb819..24fb6eb39ce 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -2252,7 +2252,7 @@ row_ins_duplicate_online(ulint n_uniq, const dtuple_t *entry,
ulint trx_id_len;
- if (fields == n_uniq
+ if (fields == n_uniq + 2
&& memcmp(rec_get_nth_field(rec, offsets, n_uniq, &trx_id_len),
reset_trx_id, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)) {
ut_ad(trx_id_len == DATA_TRX_ID_LEN);
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index 5f1b8be701e..010b347c003 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -3042,6 +3042,9 @@ row_log_apply_op_low(
mtr_start(&mtr);
index->set_modified(mtr);
cursor.page_cur.index = index;
+ if (has_index_lock) {
+ mtr_x_lock_index(index, &mtr);
+ }
/* We perform the pessimistic variant of the operations if we
already hold index->lock exclusively. First, search the
@@ -3049,7 +3052,8 @@ row_log_apply_op_low(
depending on when the row in the clustered index was
scanned. */
*error = cursor.search_leaf(entry, PAGE_CUR_LE, has_index_lock
- ? BTR_MODIFY_TREE : BTR_MODIFY_LEAF, &mtr);
+ ? BTR_MODIFY_TREE_ALREADY_LATCHED
+ : BTR_MODIFY_LEAF, &mtr);
if (UNIV_UNLIKELY(*error != DB_SUCCESS)) {
goto func_exit;
}
diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc
index f277ec4ec95..987d3d185d9 100644
--- a/storage/innobase/srv/srv0mon.cc
+++ b/storage/innobase/srv/srv0mon.cc
@@ -832,7 +832,7 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_DEFAULT_START, MONITOR_MODULE_INDEX},
{"index_page_splits", "index", "Number of index page splits",
- MONITOR_NONE,
+ MONITOR_EXISTING,
MONITOR_DEFAULT_START, MONITOR_INDEX_SPLIT},
{"index_page_merge_attempts", "index",
@@ -1240,10 +1240,12 @@ srv_mon_process_existing_counter(
/* Get the value from corresponding global variable */
switch (monitor_id) {
- /* export_vars.innodb_buffer_pool_reads. Num Reads from
- disk (page not in buffer) */
+ case MONITOR_INDEX_SPLIT:
+ value = buf_pool.pages_split;
+ break;
+
case MONITOR_OVLD_BUF_POOL_READS:
- value = srv_stats.buf_pool_reads;
+ value = buf_pool.stat.n_pages_read;
break;
/* innodb_buffer_pool_read_requests, the number of logical
@@ -1304,7 +1306,7 @@ srv_mon_process_existing_counter(
/* innodb_buffer_pool_bytes_dirty */
case MONITOR_OVLD_BUF_POOL_BYTES_DIRTY:
- value = buf_pool.stat.flush_list_bytes;
+ value = buf_pool.flush_list_bytes;
break;
/* innodb_buffer_pool_pages_free */
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 765ae8c9464..edc19126558 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -628,6 +628,7 @@ void srv_boot()
if (transactional_lock_enabled())
sql_print_information("InnoDB: Using transactional memory");
#endif
+ buf_dblwr.init();
srv_thread_pool_init();
trx_pool_init();
srv_init();
@@ -880,56 +881,19 @@ srv_export_innodb_status(void)
export_vars.innodb_data_writes = os_n_file_writes;
- ulint dblwr = 0;
-
- if (buf_dblwr.is_initialised()) {
- buf_dblwr.lock();
- dblwr = buf_dblwr.submitted();
- export_vars.innodb_dblwr_pages_written = buf_dblwr.written();
- export_vars.innodb_dblwr_writes = buf_dblwr.batches();
- buf_dblwr.unlock();
- }
+ buf_dblwr.lock();
+ ulint dblwr = buf_dblwr.submitted();
+ export_vars.innodb_dblwr_pages_written = buf_dblwr.written();
+ export_vars.innodb_dblwr_writes = buf_dblwr.batches();
+ buf_dblwr.unlock();
export_vars.innodb_data_written = srv_stats.data_written + dblwr;
- export_vars.innodb_buffer_pool_read_requests
- = buf_pool.stat.n_page_gets;
-
- export_vars.innodb_buffer_pool_reads = srv_stats.buf_pool_reads;
-
- export_vars.innodb_buffer_pool_read_ahead_rnd =
- buf_pool.stat.n_ra_pages_read_rnd;
-
- export_vars.innodb_buffer_pool_read_ahead =
- buf_pool.stat.n_ra_pages_read;
-
- export_vars.innodb_buffer_pool_read_ahead_evicted =
- buf_pool.stat.n_ra_pages_evicted;
-
- export_vars.innodb_buffer_pool_pages_data =
- UT_LIST_GET_LEN(buf_pool.LRU);
-
export_vars.innodb_buffer_pool_bytes_data =
buf_pool.stat.LRU_bytes
+ (UT_LIST_GET_LEN(buf_pool.unzip_LRU)
<< srv_page_size_shift);
- export_vars.innodb_buffer_pool_pages_dirty =
- UT_LIST_GET_LEN(buf_pool.flush_list);
-
- export_vars.innodb_buffer_pool_pages_made_young
- = buf_pool.stat.n_pages_made_young;
- export_vars.innodb_buffer_pool_pages_made_not_young
- = buf_pool.stat.n_pages_not_made_young;
-
- export_vars.innodb_buffer_pool_pages_old = buf_pool.LRU_old_len;
-
- export_vars.innodb_buffer_pool_bytes_dirty =
- buf_pool.stat.flush_list_bytes;
-
- export_vars.innodb_buffer_pool_pages_free =
- UT_LIST_GET_LEN(buf_pool.free);
-
#ifdef UNIV_DEBUG
export_vars.innodb_buffer_pool_pages_latched =
buf_get_latched_pages_number();
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 006701bada6..0a96a4fbaab 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -688,7 +688,8 @@ err_exit:
fil_set_max_space_id_if_bigger(space_id);
fil_space_t *space= fil_space_t::create(space_id, fsp_flags,
- FIL_TYPE_TABLESPACE, NULL);
+ FIL_TYPE_TABLESPACE, nullptr,
+ FIL_ENCRYPTION_DEFAULT, true);
ut_a(fil_validate());
ut_a(space);
@@ -1033,9 +1034,7 @@ ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file()
{
DBUG_ENTER("srv_prepare_to_delete_redo_log_file");
- /* Disable checkpoints in the page cleaner. */
- ut_ad(!recv_sys.recovery_on);
- recv_sys.recovery_on= true;
+ ut_ad(recv_sys.recovery_on);
/* Clean the buffer pool. */
buf_flush_sync();
@@ -1665,8 +1664,6 @@ dberr_t srv_start(bool create_new_db)
}
}
- recv_sys.debug_free();
-
if (srv_operation != SRV_OPERATION_NORMAL) {
ut_ad(srv_operation == SRV_OPERATION_RESTORE_EXPORT
|| srv_operation == SRV_OPERATION_RESTORE);
@@ -1681,6 +1678,8 @@ dberr_t srv_start(bool create_new_db)
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
}
+
+ recv_sys.debug_free();
}
ut_ad(err == DB_SUCCESS);
@@ -1982,7 +1981,7 @@ void innodb_shutdown()
ut_ad(dict_sys.is_initialised() || !srv_was_started);
ut_ad(trx_sys.is_initialised() || !srv_was_started);
- ut_ad(buf_dblwr.is_initialised() || !srv_was_started
+ ut_ad(buf_dblwr.is_created() || !srv_was_started
|| srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys.is_initialised() || !srv_was_started);
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index 45dc78b4440..99cf1364192 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -557,9 +557,13 @@ trx_release_savepoint_for_mysql(
if (savep != NULL) {
trx_roll_savepoint_free(trx, savep);
+ return DB_SUCCESS;
+ } else if (trx->last_sql_stat_start.least_undo_no == 0) {
+ /* Bulk insert could have discarded savepoints */
+ return DB_SUCCESS;
}
- return(savep != NULL ? DB_SUCCESS : DB_NO_SAVEPOINT);
+ return DB_NO_SAVEPOINT;
}
/*******************************************************************//**
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index ce7a252aa01..e88f7824ba6 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -404,6 +404,7 @@ void trx_t::free()
sizeof skip_lock_inheritance_and_n_ref);
/* do not poison mutex */
MEM_NOACCESS(&id, sizeof id);
+ MEM_NOACCESS(&max_inactive_id, sizeof id);
MEM_NOACCESS(&state, sizeof state);
MEM_NOACCESS(&is_recovered, sizeof is_recovered);
#ifdef WITH_WSREP
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
index 9d67a60cee9..d2974438ecb 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
@@ -164,7 +164,7 @@ compress_pages_page_decompressed compression 0 NULL NULL NULL 0 NULL NULL NULL N
compress_pages_page_compression_error compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of page compression errors
compress_pages_encrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages encrypted
compress_pages_decrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decrypted
-index_page_splits index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page splits
+index_page_splits index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of index page splits
index_page_merge_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page merge attempts
index_page_merge_successful index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of successful index page merges
index_page_reorg_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page reorganization attempts
diff --git a/storage/spider/mysql-test/spider/r/error_row_number.result b/storage/spider/mysql-test/spider/r/error_row_number.result
index cc2b54878a0..ad095fe8ebd 100644
--- a/storage/spider/mysql-test/spider/r/error_row_number.result
+++ b/storage/spider/mysql-test/spider/r/error_row_number.result
@@ -29,7 +29,7 @@ ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
get diagnostics condition 1 @n = row_number;
select @n;
@n
-0
+1
drop table spd;
connection child2_1;
drop database auto_test_remote;
diff --git a/support-files/mini-benchmark.sh b/support-files/mini-benchmark.sh
index d5dd194bc3f..18de6dbec51 100755
--- a/support-files/mini-benchmark.sh
+++ b/support-files/mini-benchmark.sh
@@ -106,16 +106,29 @@ then
done | sort -u > mariadbd-dependencies.txt
# shellcheck disable=SC2046
debuginfo-install -y mariadb-server $(cat mariadbd-dependencies.txt)
-
- echo "Using 'perf' to record performance counters in perf.data files"
- PERF="perf record -g --freq=99 --output=perf.data --timestamp-filename --pid=$MARIADB_SERVER_PID --"
+
+ if [ ! $(perf record echo "testing perf" > /dev/null 2>&1) ]
+ then
+ echo "perf does not have permission to run on this system. Skipping."
+ PERF=""
+ else
+ echo "Using 'perf' to record performance counters in perf.data files"
+ PERF="perf record -g --freq=99 --output=perf.data --timestamp-filename --pid=$MARIADB_SERVER_PID --"
+ fi
elif [ -e /usr/bin/perf ]
then
# If flamegraphs were not requested, log normal perf counters if possible
- echo "Using 'perf' to log basic performance counters for benchmark"
+
+ if [ ! $(perf stat echo "testing perf" > /dev/null 2>&1) ]
+ then
+ echo "perf does not have permission to run on this system. Skipping."
+ PERF=""
+ else
+ echo "Using 'perf' to log basic performance counters for benchmark"
+ PERF="perf stat -p $MARIADB_SERVER_PID --"
+ fi
fi
- PERF="perf stat -p $MARIADB_SERVER_PID --"
# Run sysbench on another CPU if system has more than one available
if [ "$(nproc)" -gt 1 ]
@@ -133,10 +146,10 @@ uname -a
echo
echo "Set highest priority for MariaDB Server process ID $MARIADB_SERVER_PID"
-renice --priority -20 --pid "$MARIADB_SERVER_PID"
+renice --priority -20 --pid "$MARIADB_SERVER_PID" || echo "renice failed. Not setting priority."
echo "Set CPU affinity 0 for MariaDB Server process ID $MARIADB_SERVER_PID"
-taskset -cp 0 "$MARIADB_SERVER_PID"
+taskset -cp 0 "$MARIADB_SERVER_PID" || echo "taskset failed. Not setting cpu affinity."
mariadb -e "
CREATE DATABASE IF NOT EXISTS sbtest;