| 1 |
|
| 2 |
--disable_warnings |
| 3 |
DROP TABLE IF EXISTS t1, t2; |
| 4 |
DROP VIEW IF EXISTS v_t1; |
| 5 |
--enable_warnings |
| 6 |
|
| 7 |
# Create a base table and a view |
| 8 |
CREATE TABLE t1 (id INT PRIMARY KEY); |
| 9 |
CREATE view v_t1 AS SELECT * FROM t1; |
| 10 |
|
| 11 |
# Verify the base table and view is supported |
| 12 |
CALL sys.table_exists('test', 't1', @exists); |
| 13 |
SELECT @exists; |
| 14 |
|
| 15 |
CALL sys.table_exists('test', 'v_t1', @exists); |
| 16 |
SELECT @exists; |
| 17 |
|
| 18 |
# Replace the base table with a temporary table |
| 19 |
CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY); |
| 20 |
CALL sys.table_exists('test', 't1', @exists); |
| 21 |
SELECT @exists; |
| 22 |
|
| 23 |
# Try a non-existing table |
| 24 |
CALL sys.table_exists('test', 't2', @exists); |
| 25 |
SELECT @exists; |
| 26 |
|
| 27 |
# Try variables longer than expected |
| 28 |
SET @identifier := REPEAT('a', 65); |
| 29 |
|
| 30 |
-- error 1406 |
| 31 |
CALL sys.table_exists(@identifier, 't1', @exists); |
| 32 |
|
| 33 |
-- error 1406 |
| 34 |
CALL sys.table_exists('test', @identifier, @exists); |
| 35 |
|
| 36 |
# Clean up |
| 37 |
DROP TEMPORARY TABLE t1; |
| 38 |
DROP TABLE t1; |
| 39 |
DROP VIEW v_t1; |
| 40 |
SET @identifier := NULL; |