File: test_mysql_command_services_component.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (84 lines) | stat: -rw-r--r-- 3,204 bytes parent folder | download
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
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";