INSTALL COMPONENT "file://component_test_mysql_command_services"; --echo # Test : sending no arguments. SELECT test_mysql_command_services_udf(); --echo # Test : should return '2' the output of SELECT 1+1; SELECT test_mysql_command_services_udf("select 1+1"); --echo # Test : should return '2.5' the output of SELECT 1.3+1.2; SELECT test_mysql_command_services_udf("select 1.3+1.2"); --echo # Test : should return TIMESTAMP SELECT test_mysql_command_services_udf("SELECT TIMESTAMP('2003-12-31')"); --echo # Test : should return DATE SELECT test_mysql_command_services_udf("SELECT FROM_DAYS(730669)"); --echo # Test : should return TIME --disable_result_log SELECT test_mysql_command_services_udf("SELECT CURTIME()"); --enable_result_log CREATE TABLE test.t1 (c1 int, c2 char(13)); INSERT INTO test.t1 VALUES (1, "foo"), (2, "bar"), (3, "zap"); SELECT * FROM test.t1; SELECT test_mysql_command_services_udf("SELECT * FROM test.t1"); CREATE TABLE test.t2 (c1 int, c2 float); INSERT INTO test.t2 VALUES (1, 1.1), (2, 2.2), (3, 3.3); SELECT * FROM test.t2; SELECT test_mysql_command_services_udf("SELECT * FROM test.t2"); CREATE TABLE test.t3 (c1 int, c2 double); INSERT INTO test.t3 VALUES (1, 1.11), (2, 2.22), (3, 3.33); SELECT * FROM test.t3; SELECT test_mysql_command_services_udf("SELECT * FROM test.t3"); CREATE TABLE test.t4 (c1 int, c2 decimal(5,3)); INSERT INTO test.t4 VALUES (1, 1.111), (2, 2.222), (3, 3.333); SELECT * FROM test.t4; SELECT test_mysql_command_services_udf("SELECT * FROM test.t4"); --echo The output is truncated to MAX_FIELD_WIDTH size, this is --echo because the udf buffer is of that size. CREATE TABLE test.t5 (c1 int, c2 varchar(1000)); INSERT INTO test.t5 VALUES (1, repeat('a',1000)); SELECT * FROM test.t5; SELECT test_mysql_command_services_udf("SELECT * FROM test.t5"); --echo # Test : should return error message --error ER_COMMAND_SERVICE_BACKEND_FAILED SELECT test_mysql_command_services_udf("SELECT * FROM mysql.plugin ORDER BY name"); --echo # Test : should return error message BUG#34035897 --error ER_COMMAND_SERVICE_BACKEND_FAILED SELECT test_mysql_command_services_udf("SELECT * FROM information_schema.innodb_tables"); --disable_result_log SELECT test_mysql_command_services_udf("SELECT * FROM information_schema.COLLATION_CHARACTER_SET_APPLICABILITY"); --enable_result_log --echo # Test : should return NULL field value if exits BUG#34026180 CREATE TABLE test.t6(c1 int, c2 text); INSERT INTO test.t6 VALUES(1, 'FOO'); SELECT test_mysql_command_services_udf("INSERT INTO test.t6(c2) VALUES('BAR')"); SELECT test_mysql_command_services_udf("SELECT c1,c2 FROM test.t6"); --echo # Test: reusing the same connection to run several queries should not crash SELECT test_mysql_command_services_udf("SELECT 1"); SELECT test_mysql_command_services_udf("SELECT 1", 2); SELECT test_mysql_command_services_apis_udf(); SELECT test_mysql_command_services_apis_udf("SELECT 1+1"); --echo The test.my_demo_transaction table is created inside above udf function DROP TABLE test.my_demo_transaction; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; DROP TABLE t5; DROP TABLE t6; UNINSTALL COMPONENT "file://component_test_mysql_command_services";