1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-20 09:07:44 +03:00

94 lines
2.0 KiB
Plaintext

#
# Test TRUNCATE TABLE in various possible scenarios.
#
-- source ../include/have_columnstore.inc
-- source include/have_innodb.inc
--disable_warnings
DROP DATABASE IF EXISTS mcs14_db1;
--enable_warnings
CREATE DATABASE mcs14_db1;
USE mcs14_db1;
CREATE TABLE t1 (a INTEGER, b INT,c1 CHAR(10)) ENGINE=Columnstore;
INSERT INTO t1 (a) VALUES (1),(2);
TRUNCATE TABLE t1;
SELECT COUNT(*) FROM t1;
INSERT INTO t1 VALUES (1, 2, "test");
SELECT COUNT(*) FROM t1;
TRUNCATE mcs14_db1.t1;
DROP TABLE IF EXISTS non_existing_table;
--error 1146
TRUNCATE non_existing_table;
# check multi-table TRUNCATE
DROP TABLE t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (id INT) ENGINE=INNODB;
CREATE TABLE t2 (id INT) ENGINE=Columnstore;
--error 1064
TRUNCATE t1, t2;
TRUNCATE t1;
TRUNCATE t2;
DROP TABLE t1;
DROP TABLE t2;
# Test for Bug#5507 "TRUNCATE should work with views"
#
# when it'll be fixed, the error should become 1347
# (test.v1' is not of type 'BASE TABLE')
#
CREATE TABLE t1 (id INT) ENGINE=Columnstore;
INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5);
CREATE VIEW v1 AS SELECT * FROM t1;
--error 1146
TRUNCATE v1;
SELECT * FROM v1;
--error ER_NO_SUCH_TABLE
TRUNCATE v1;
SELECT * FROM v1;
CREATE PROCEDURE p1() SET @a = 5;
--error ER_NO_SUCH_TABLE
TRUNCATE p1;
# Test with handler
DROP TABLE t1;
CREATE TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT) ENGINE=Columnstore;
INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5);
CREATE TABLE t2 LIKE t1;
INSERT INTO t2 SELECT * FROM t1;
# Test from parallel connections
connect (addconroot1, localhost, root,,);
connect (addconroot2, localhost, root,,);
connection addconroot1;
TRUNCATE mcs14_db1.t1;
connection addconroot2;
TRUNCATE mcs14_db1.t1;
connection addconroot1;
TRUNCATE mcs14_db1.t1;
connection addconroot2;
USE mcs14_db1;
TRUNCATE t2;
connection default;
USE mcs14_db1;
SELECT count(*) FROM t1;
SELECT count(*) FROM t2;
disconnect addconroot1;
disconnect addconroot2;
--disable_warnings
DROP DATABASE mcs14_db1;
--enable_warnings
#