summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/timezone.result13
-rw-r--r--mysql-test/main/timezone.test15
-rw-r--r--sql/tztime.cc6
3 files changed, 33 insertions, 1 deletions
diff --git a/mysql-test/main/timezone.result b/mysql-test/main/timezone.result
index b679a8cdcbd..2ba1e3fb1d5 100644
--- a/mysql-test/main/timezone.result
+++ b/mysql-test/main/timezone.result
@@ -62,3 +62,16 @@ NULL NULL NULL
#
# End of 4.1 tests
#
+#
+# MDEV-27393 Timezone tables cannot have descending indexes
+#
+call mtr.add_suppression('mysql.time_zone_transition_type table is incorrectly defined or corrupted');
+alter table mysql.time_zone_transition_type drop primary key;
+alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id desc);
+SET @@time_zone='Japan';
+ERROR HY000: Unknown or incorrect time zone: 'Japan'
+alter table mysql.time_zone_transition_type drop primary key;
+alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id);
+#
+# End of 10.8 tests
+#
diff --git a/mysql-test/main/timezone.test b/mysql-test/main/timezone.test
index 57eefa92b27..89c3ab5cfc1 100644
--- a/mysql-test/main/timezone.test
+++ b/mysql-test/main/timezone.test
@@ -59,3 +59,18 @@ select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:0
--echo #
--echo # End of 4.1 tests
--echo #
+
+--echo #
+--echo # MDEV-27393 Timezone tables cannot have descending indexes
+--echo #
+call mtr.add_suppression('mysql.time_zone_transition_type table is incorrectly defined or corrupted');
+alter table mysql.time_zone_transition_type drop primary key;
+alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id desc);
+--error ER_UNKNOWN_TIME_ZONE
+SET @@time_zone='Japan';
+alter table mysql.time_zone_transition_type drop primary key;
+alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id);
+
+--echo #
+--echo # End of 10.8 tests
+--echo #
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 1f393e24ec2..f01fc9e5485 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -2004,7 +2004,11 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#endif
/* ttid is increasing because we are reading using index */
- DBUG_ASSERT(ttid >= tmp_tz_info.typecnt);
+ if (ttid < tmp_tz_info.typecnt)
+ {
+ sql_print_error("mysql.time_zone_transition_type table is incorrectly defined or corrupted");
+ goto end;
+ }
tmp_tz_info.typecnt= ttid + 1;