Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 12.3.2
Description
Description
MariaDB Server 12.3.2 returns `InternalError (126)` with `Index is corrupted` for a server-created `/tmp/#sql-temptable-*.MAI` file during SELECT execution. The statement combines INTERSECT, EXCEPT, an ALL subquery and correlated subqueries.
How to repeat
Use an isolated MariaDB 12.3.2 instance. Execute each complete block below, including the final SELECT. Each block drops/recreates only its named `aria_schema_*` database and sets session variables. All reproduction SQL is included inline.
3 total rows (`t1`: 2, `t2`: 1, `t3`: 0); 16 columns across three tables. Empty tables remain because the SELECT still references them. The failing SELECT is preserved verbatim from the original discovery file.
-- MariaDB 12.3.2; isolated database; original failing SELECT unchanged.
|
DROP DATABASE IF EXISTS `aria_schema_a`;
|
|
|
CREATE DATABASE `aria_schema_a`;
|
|
|
USE `aria_schema_a`;
|
|
|
SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_ai_ci;
|
|
|
SET SESSION sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
|
|
|
SET SESSION max_statement_time=5;
|
|
|
SET SESSION sort_buffer_size=67108864, read_rnd_buffer_size=8388608;
|
|
|
CREATE TABLE `t1` (
|
`c1` int(11) DEFAULT NULL,
|
`c2` varchar(255) DEFAULT NULL,
|
`c3` varchar(255) DEFAULT NULL,
|
`c4` int(11) DEFAULT NULL,
|
`c6` varchar(10) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
|
|
INSERT INTO `t1` (`c1`,`c2`,`c3`,`c4`,`c6`) VALUES
|
(0,'','',28,''),
|
(28,'','',1,'');
|
|
|
CREATE TABLE `t2` (
|
`c2` int(11) DEFAULT NULL,
|
`c3` decimal(10,2) DEFAULT NULL,
|
`c6` mediumtext DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
|
|
INSERT INTO `t2` (`c2`,`c3`,`c6`) VALUES
|
(0,0,'');
|
|
|
CREATE TABLE `t3` (
|
`c1` int(11) DEFAULT NULL,
|
`c2` int(11) DEFAULT NULL,
|
`c5` datetime DEFAULT NULL,
|
`c7` smallint(6) DEFAULT NULL,
|
`c8` mediumint(9) DEFAULT NULL,
|
`c9` bigint(20) DEFAULT NULL,
|
`c11` varchar(255) DEFAULT NULL,
|
`c13` tinyblob DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
|
|
-- Original failing SELECT.
|
(SELECT (SELECT (t3.c4 - t3.c1) AS subq_col_1 FROM t1 AS t3 WHERE t3.c1 < sq1.q1_col_4 ORDER BY subq_col_1 DESC LIMIT 1) AS q2_col_1, sq1.q1_col_4 AS q2_col_2, STR_TO_DATE(sq1.q1_col_2, sq1.q1_col_2) AS q2_col_3 FROM (SELECT DISTINCT t2.c1 AS q1_col_1, t2.c2 AS q1_col_2, t2.c4 AS q1_col_3, t2.c1 AS q1_col_4 FROM t1 AS t2 WHERE t2.c6 > t2.c6 AND t2.c3 NOT LIKE '%sample_92%') AS sq1 WHERE NOT sq1.q1_col_4 IS NOT NULL GROUP BY sq1.q1_col_4, sq1.q1_col_2, sq1.q1_col_3 HAVING 37 >= ((sq1.q1_col_3 * 7) + 56) INTERSECT SELECT t5.c2 AS q5_col_1, t5.c1 AS q5_col_2, t5.c5 AS q5_col_3 FROM t1 AS t4 LEFT JOIN t3 AS t5 ON t4.c6 <> t5.c11 JOIN t2 AS t6 ON t4.c1 = ALL (SELECT t8.c4 AS q3_col_1 FROM t3 AS t7 RIGHT JOIN t1 AS t8 ON t7.c9 > t8.c1 LEFT JOIN t2 AS t9 ON TRUE = FALSE WHERE 1 = 1 INTERSECT SELECT t10.c13 AS q4_col_1 FROM t3 AS t10 WHERE t10.c8 <= t6.c3)) EXCEPT SELECT t11.c7 AS q6_col_1, CAST(23 AS DECIMAL) AS q6_col_2, CAST('2023-01-01' AS DATETIME) AS q6_col_3 FROM t3 AS t11 LEFT JOIN t2 AS t12 ON t11.c1 >= t12.c2 AND t12.c6 IS NULL RIGHT JOIN t1 AS t13 ON t11.c7 IN (SELECT 75 AS subq_col_1 FROM t3 AS t14 WHERE t14.c1 NOT BETWEEN 14 AND 48);
|
Actual result
|
|
InternalError (126): Got error '126 "Index is corrupted"' for '/tmp/#sql-temptable-1-14-556.MAI' |
Attachments
Issue Links
- relates to
-
MDEV-42158 Error 127 "Table file is corrupted" on internal Aria temporary tables during SELECT
-
- Confirmed
-