Debian Codegraph @

mysql-test/suite/x/t/admin_list_objects.test

raw
1 ## Simple list objects
2
3 --source include/xplugin_preamble.inc
4 --source include/xplugin_create_user.inc
5
6 CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
7 CREATE TABLE xtest.mytable (a INT);
8 CREATE TABLE xtest.mytable2 (a INT, doc JSON);
9 CREATE VIEW xtest.myview AS SELECT 1;
10
11 ## Test starts here
12 --let $xtest_file= $MYSQL_TMP_DIR/admin_list_objects_mysqlx.xpl
13 --write_file $xtest_file
14 -->quiet
15 ## Test data
16
17 -->stmtadmin create_collection {"schema":"xtest", "name":"books"}
18 -->recvresult
19
20
21 -->sql
22 CREATE VIEW xtest.fakecoll AS SELECT * FROM xtest.books;
23 CREATE VIEW xtest.xdoc AS SELECT doc FROM xtest.mytable2;
24 CREATE VIEW xtest.fakexview AS SELECT doc, a AS _id FROM xtest.mytable2;
25
26 -->endsql
27
28
29 -->stmtadmin list_objects {"schema":"xtest"}
30 -->recvresult
31
32
33 -->stmtadmin list_objects {"schema":"invalid"}
34 -->expecterror 1049
35 -->recvresult
36
37
38 -->stmtadmin list_objects {"schema":"xtest","pattern":"myt%"}
39 -->recvresult
40
41 ## empty resultset
42 -->stmtadmin list_objects {"schema":"xtest","pattern":"bla%"}
43 -->recvresult
44
45
46 -->stmtadmin list_objects
47 -->expecterror 1046
48 -->recvresult
49
50
51 -->sql
52 USE xtest
53 -->endsql
54
55 -->stmtadmin list_objects
56 -->recvresult
57
58
59 -->stmtadmin list_objects {"pattern":"fa%"}
60 -->recvresult
61
62
63 -->stmtsql ALTER TABLE xtest.books ADD COLUMN (nothing INT)
64 -->recvresult
65
66 -->stmtsql show columns from xtest.books
67 -->recvresult
68
69 -->stmtadmin list_objects {"pattern":"books"}
70 -->recvresult
71
72
73 -->stmtadmin list_objects
74 -->recvresult
75 -->stmtsql DROP TABLE xtest.books
76 -->recvresult
77 -->stmtadmin list_objects
78 -->recvresult
79
80
81 -->stmtadmin list_objects {"schema":"sys", "pattern":"processlist"}
82 -->recvresult
83
84 -->title -Collection with index
85 -->stmtadmin create_collection {"schema":"xtest", "name":"fruit"}
86 -->recvresult
87 -->stmtadmin create_collection_index {"schema":"xtest", "collection":"fruit", "name": "fruit_name", "unique": true, "fields":{"field": "$.name", "type": "text(20)", "required": false}}
88 -->recvresult
89 -->stmtadmin list_objects {"schema":"xtest", "pattern":"fruit"}
90 -->recvresult
91
92 -->title -Collection with validation schema
93 stmtadmin create_collection {"schema":"xtest", "name":"stuff", "options": {
94 "validation": {
95 "schema":{"id": "foobar"}
96 }
97 }};
98 -->recvresult
99 stmtadmin create_collection_index {
100 "schema":"xtest",
101 "collection":"stuff",
102 "name": "stuff_name",
103 "unique": true,
104 "constraint":{"member": "$.name", "type": "text(20)", "required": false}
105 };
106 -->recvresult
107 -->stmtadmin list_objects {"schema":"xtest", "pattern":"stuff"}
108 -->recvresult
109
110 -->title -Removing `_id` from collection
111 -->stmtsql ALTER TABLE xtest.fruit DROP COLUMN _id;
112 -->recvresult
113 -->stmtadmin list_objects {"schema":"xtest", "pattern":"fruit"}
114 -->recvresult
115
116 -->title -Removing `_id` and index from collection
117 -->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fruit", "name": "fruit_name"}
118 -->recvresult
119 -->stmtadmin list_objects {"schema":"xtest", "pattern":"fruit"}
120 -->recvresult
121 EOF
122
123 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1
124
125 ## Cleanup
126 --source ../include/xplugin_cleanup.inc