| 1 |
INSTALL COMPONENT "file://component_test_mysql_command_services"; |
| 2 |
|
| 3 |
--echo # Test : sending no arguments. |
| 4 |
SELECT test_mysql_command_services_udf(); |
| 5 |
|
| 6 |
--echo # Test : should return '2' the output of SELECT 1+1; |
| 7 |
SELECT test_mysql_command_services_udf("select 1+1"); |
| 8 |
|
| 9 |
--echo # Test : should return '2.5' the output of SELECT 1.3+1.2; |
| 10 |
SELECT test_mysql_command_services_udf("select 1.3+1.2"); |
| 11 |
|
| 12 |
--echo # Test : should return TIMESTAMP |
| 13 |
SELECT test_mysql_command_services_udf("SELECT TIMESTAMP('2003-12-31')"); |
| 14 |
|
| 15 |
--echo # Test : should return DATE |
| 16 |
SELECT test_mysql_command_services_udf("SELECT FROM_DAYS(730669)"); |
| 17 |
|
| 18 |
--echo # Test : should return TIME |
| 19 |
--disable_result_log |
| 20 |
SELECT test_mysql_command_services_udf("SELECT CURTIME()"); |
| 21 |
--enable_result_log |
| 22 |
|
| 23 |
CREATE TABLE test.t1 (c1 int, c2 char(13)); |
| 24 |
INSERT INTO test.t1 VALUES (1, "foo"), (2, "bar"), (3, "zap"); |
| 25 |
SELECT * FROM test.t1; |
| 26 |
SELECT test_mysql_command_services_udf("SELECT * FROM test.t1"); |
| 27 |
|
| 28 |
CREATE TABLE test.t2 (c1 int, c2 float); |
| 29 |
INSERT INTO test.t2 VALUES (1, 1.1), (2, 2.2), (3, 3.3); |
| 30 |
SELECT * FROM test.t2; |
| 31 |
SELECT test_mysql_command_services_udf("SELECT * FROM test.t2"); |
| 32 |
|
| 33 |
CREATE TABLE test.t3 (c1 int, c2 double); |
| 34 |
INSERT INTO test.t3 VALUES (1, 1.11), (2, 2.22), (3, 3.33); |
| 35 |
SELECT * FROM test.t3; |
| 36 |
SELECT test_mysql_command_services_udf("SELECT * FROM test.t3"); |
| 37 |
|
| 38 |
CREATE TABLE test.t4 (c1 int, c2 decimal(5,3)); |
| 39 |
INSERT INTO test.t4 VALUES (1, 1.111), (2, 2.222), (3, 3.333); |
| 40 |
SELECT * FROM test.t4; |
| 41 |
SELECT test_mysql_command_services_udf("SELECT * FROM test.t4"); |
| 42 |
|
| 43 |
--echo The output is truncated to MAX_FIELD_WIDTH size, this is |
| 44 |
--echo because the udf buffer is of that size. |
| 45 |
CREATE TABLE test.t5 (c1 int, c2 varchar(1000)); |
| 46 |
INSERT INTO test.t5 VALUES (1, repeat('a',1000)); |
| 47 |
SELECT * FROM test.t5; |
| 48 |
SELECT test_mysql_command_services_udf("SELECT * FROM test.t5"); |
| 49 |
|
| 50 |
--echo # Test : should return error message |
| 51 |
--error ER_COMMAND_SERVICE_BACKEND_FAILED |
| 52 |
SELECT test_mysql_command_services_udf("SELECT * FROM mysql.plugin ORDER BY name"); |
| 53 |
|
| 54 |
--echo # Test : should return error message BUG#34035897 |
| 55 |
--error ER_COMMAND_SERVICE_BACKEND_FAILED |
| 56 |
SELECT test_mysql_command_services_udf("SELECT * FROM information_schema.innodb_tables"); |
| 57 |
|
| 58 |
--disable_result_log |
| 59 |
SELECT test_mysql_command_services_udf("SELECT * FROM information_schema.COLLATION_CHARACTER_SET_APPLICABILITY"); |
| 60 |
--enable_result_log |
| 61 |
|
| 62 |
--echo # Test : should return NULL field value if exits BUG#34026180 |
| 63 |
CREATE TABLE test.t6(c1 int, c2 text); |
| 64 |
INSERT INTO test.t6 VALUES(1, 'FOO'); |
| 65 |
SELECT test_mysql_command_services_udf("INSERT INTO test.t6(c2) VALUES('BAR')"); |
| 66 |
SELECT test_mysql_command_services_udf("SELECT c1,c2 FROM test.t6"); |
| 67 |
|
| 68 |
--echo # Test: reusing the same connection to run several queries should not crash |
| 69 |
SELECT test_mysql_command_services_udf("SELECT 1"); |
| 70 |
SELECT test_mysql_command_services_udf("SELECT 1", 2); |
| 71 |
|
| 72 |
SELECT test_mysql_command_services_apis_udf(); |
| 73 |
SELECT test_mysql_command_services_apis_udf("SELECT 1+1"); |
| 74 |
--echo The test.my_demo_transaction table is created inside above udf function |
| 75 |
DROP TABLE test.my_demo_transaction; |
| 76 |
|
| 77 |
DROP TABLE t1; |
| 78 |
DROP TABLE t2; |
| 79 |
DROP TABLE t3; |
| 80 |
DROP TABLE t4; |
| 81 |
DROP TABLE t5; |
| 82 |
DROP TABLE t6; |
| 83 |
|
| 84 |
UNINSTALL COMPONENT "file://component_test_mysql_command_services"; |