Debian Codegraph @

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

raw
1 ## Inserting values described as an expressions
2
3 ## Preamble
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6 ## Test starts here
7 --write_file $MYSQL_TMP_DIR/crud_insert_expr.xpl
8 ## Test data
9 -->quiet
10 -->sql
11 DROP SCHEMA IF EXISTS xtest;
12 CREATE SCHEMA xtest;
13 CREATE TABLE xtest.mytable (id INT PRIMARY KEY, name VARCHAR(40), flag BOOL);
14 -->endsql
15
16 Mysqlx.Crud.Insert {
17 collection { name: "mytable" schema: "xtest"}
18 data_model: TABLE
19 projection {name: "id"}
20 projection {name: "name"}
21 projection {name: "flag"}
22 row {
23 field {
24 type: OPERATOR operator {
25 name: "+"
26 param {
27 type : LITERAL
28 literal { type: V_SINT v_signed_int: 19 }
29 }
30 param {
31 type : LITERAL
32 literal { type: V_SINT v_signed_int: 23 }
33 }
34 }
35 }
36 field {
37 type: FUNC_CALL function_call {
38 name {
39 name: "upper"
40 }
41 param {
42 type: LITERAL
43 literal { type: V_STRING v_string { value: "Robb" } }
44 }
45 }
46 }
47 field {
48 type: OPERATOR operator {
49 name: "<"
50 param {
51 type: FUNC_CALL function_call {
52 name { name: "now" }
53 }
54 }
55 param {
56 type: FUNC_CALL function_call {
57 name { name: "makedate" }
58 param {
59 type : LITERAL
60 literal { type: V_SINT v_signed_int: 2015 }
61 }
62 param {
63 type : LITERAL
64 literal { type: V_SINT v_signed_int: 15 }
65 }
66 }
67 }
68 }
69 }
70 }
71 }
72
73 #-- Mysqlx.Sql.StmtExecuteOk
74 -->recvresult
75
76 -->sql
77 SELECT * FROM xtest.mytable;
78 -->endsql
79
80 -->stmtadmin create_collection {"schema":"xtest","name":"mycoll"}
81 -->recvresult
82
83 Mysqlx.Crud.Insert {
84 collection {
85 name: "mycoll"
86 schema: "xtest"
87 }
88 data_model: DOCUMENT
89 row {
90 field {
91 type: FUNC_CALL function_call {
92 name { name: "replace" }
93 param {
94 type: LITERAL
95 literal {
96 type: V_STRING v_string { value: "{\"_id\": \"one\", \"value\": 77}" }
97 }
98 }
99 param {
100 type: LITERAL
101 literal {
102 type: V_STRING v_string { value: "one" }
103 }
104 }
105 param {
106 type: FUNC_CALL function_call {
107 name { name: "hex" }
108 param {
109 type: LITERAL
110 literal {
111 type: V_STRING v_string { value: "two" }
112 }
113 }
114 }
115 }
116 }
117 }
118 }
119 }
120 -->recvresult
121
122 Mysqlx.Crud.Insert {
123 collection {
124 name: "mycoll"
125 schema: "xtest"
126 }
127 data_model: DOCUMENT
128 row {
129 field {
130 type: OBJECT object {
131 fld {
132 key: '_id'
133 value {
134 type: FUNC_CALL function_call {
135 name { name: "hex" }
136 param {
137 type: LITERAL literal {
138 type: V_STRING v_string { value: "three" }
139 }
140 }
141 }
142 }
143 }
144 fld {
145 key: 'value'
146 value {
147 type: LITERAL literal { type: V_UINT v_unsigned_int: 88 }
148 }
149 }
150 }
151 }
152 }
153 }
154
155 -->recvresult
156
157 -->sql
158 SELECT hex("one");
159 SELECT hex("two");
160 SELECT doc, _id FROM xtest.mycoll;
161 -->endsql
162
163 ## Cleanup
164 -->sql
165 drop schema if exists xtest;
166 -->endsql
167 EOF
168
169 --exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/crud_insert_expr.xpl 2>&1
170
171 ## Cleanup
172 --source ../include/xplugin_cleanup.inc