summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/maria/create.test
blob: 3937d800fed2120a6b9810874723622a19943a38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--source include/have_maria.inc

# MDEV-17021
# Server crash or assertion `length <= column->length' failure in
# write_block_record
#

CREATE OR REPLACE TABLE t1 (
  f1 DECIMAL(43,0) NOT NULL,
  f2 TIME(4) NULL,
  f3 BINARY(101) NULL,
  f4 TIMESTAMP(4) NULL,
  f5 DATETIME(1) NULL,
  f6 SET('a','b','c') NOT NULL DEFAULT 'a',
  f7 VARBINARY(2332) NOT NULL DEFAULT '',
  f8 DATE NULL,
  f9 BLOB NULL,
  f10 MEDIUMINT(45) NOT NULL DEFAULT 0,
  f11 YEAR NULL,
  f12 BIT(58) NULL,
  v2 TIME(1) AS (f2) VIRTUAL,
  v3 BINARY(115) AS (f3) VIRTUAL,
  v4 TIMESTAMP(3) AS (f4) VIRTUAL,
  v7 VARBINARY(658) AS (f7) PERSISTENT,
  v8 DATE AS (f8) PERSISTENT,
  v9 TINYTEXT AS (f9) PERSISTENT,
  v11 YEAR AS (f11) VIRTUAL
) ENGINE=Aria;
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
 (0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
DROP TABLE t1;

#
# MDEV-17067 Server crash in write_block_record
#

CREATE OR REPLACE TABLE t1 (a INT(45));
INSERT IGNORE INTO t1 VALUES (1),(2);

CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
select * from t2;
DROP TABLE t1, t2;

--echo #
--echo # MDEV-23159 Assertion `table_share->tmp_table != NO_TMP_TABLE ||
--echo # m_lock_type != 2' + SIGSEGV in trnman_can_read_from
--echo # (on optimized builds)
--echo #

SET @org_sql_mode=@@SQL_MODE;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=Aria ROW_FORMAT=COMPRESSED;
INSERT INTO t1 VALUES(1);
CREATE TEMPORARY TABLE t2(b INT);
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM t2);
DROP TABLE t1,t2;

SET SQL_MODE='';
CREATE TABLE t1 (c INT PRIMARY KEY) ENGINE=Aria;
CREATE TABLE t2 (d INT);
INSERT INTO t1 VALUES (1);
SELECT c FROM t1 WHERE (c) IN (SELECT MIN(c) FROM t2);
DROP TABLE t1,t2;

USE test;
SET SQL_MODE='ONLY_FULL_GROUP_BY';
CREATE TABLE t3 (c1 DECIMAL(1,1) PRIMARY KEY,c2 DATE,c3 NUMERIC(10) UNSIGNED) ENGINE=Aria;
CREATE TABLE t2 (f1 INTEGER ) ENGINE=Aria;
INSERT INTO t3 VALUES (0,0,0);
SELECT c1 FROM t3 WHERE (c1) IN (SELECT MIN(DISTINCT c1) FROM t2);
DROP TABLE t2,t3;
SET @@SQL_MODE=@org_sql_mode;

--echo #
--echo # MDEV-23222 SIGSEGV in maria_status | Assertion `(longlong)
--echo # thd->status_var.local_memory_used >= 0
--echo #

let $mysqld_datadir= `select @@datadir`;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--eval CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = '$MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;
flush tables;
--remove_file $mysqld_datadir/test/MDEV_23222.frm
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--error 1,ER_TABLE_EXISTS_ERROR
--eval CREATE TABLE MDEV_23222 (i INT) DATA DIRECTORY = '$MYSQL_TMP_DIR', ENGINE=Aria TRANSACTIONAL=1;
DROP TABLE t1;

--echo #
--echo # End of 10.3 tests
--echo #

#
# MDEV-22686 # Assertion `trn' failed in ha_maria::start_stmt
# ASAN heap-after-free in maria_status
#

CREATE TABLE t1 (a INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (b INT);
CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1;
SELECT * from t1;
SELECT * from t2;

# Check also BEGIN/COMMIT

BEGIN;
CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1;
SELECT * from t2;
COMMIT;

# Check also LOCK TABLES

LOCK TABLES t1 read, t2 write;
CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1;
SELECT * from t2;
UNLOCK TABLES;

# Check with 3 tables
CREATE TABLE t3 (a INT) engine=Aria;
INSERT INTO t3 values(2);

CREATE OR REPLACE TABLE t2 AS SELECT t1.a,t3.a as b FROM t1,t3;
SELECT * from t2;

DROP TABLE t1, t2, t3;