Debian Codegraph @

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

raw
1 ## Inserting with default values
2
3 ## Preamble
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6
7 ## Test starts here
8 CREATE SCHEMA xtest;
9 CREATE TABLE xtest.table (id INT DEFAULT 0, name VARCHAR(40) DEFAULT 'Bob', value FLOAT DEFAULT 3.14 );
10 CREATE TABLE xtest.fault (value INT NOT NULL);
11
12 --write_file $MYSQL_TMP_DIR/crud_insert_default.xpl
13 ## Test data
14 Mysqlx.Crud.Insert {
15 collection { name: "table" schema: "xtest"}
16 data_model: TABLE
17 projection {name: "id"}
18 projection {name: "name"}
19 projection {name: "value"}
20 row {
21 field {
22 type: LITERAL literal { type: V_SINT v_signed_int: 1 }
23 }
24 field {
25 type: LITERAL literal { type: V_STRING v_string { value: "Ann" }}
26 }
27 field {
28 type: LITERAL literal { type: V_FLOAT v_float: 10.1 }
29 }
30 }
31 row {
32 field {
33 type: OPERATOR operator { name: "default" }
34 }
35 field {
36 type: LITERAL literal { type: V_STRING v_string { value: "Cezar" }}
37 }
38 field {
39 type: LITERAL literal { type: V_FLOAT v_float: 10.2 }
40 }
41 }
42 row {
43 field {
44 type: LITERAL literal { type: V_SINT v_signed_int: 2 }
45 }
46 field {
47 type: OPERATOR operator { name: "default" }
48 }
49 field {
50 type: LITERAL literal { type: V_FLOAT v_float: 10.3 }
51 }
52 }
53 row {
54 field {
55 type: LITERAL literal { type: V_SINT v_signed_int: 3 }
56 }
57 field {
58 type: LITERAL literal { type: V_STRING v_string { value: "Don" }}
59 }
60 field {
61 type: OPERATOR operator { name: "default" }
62 }
63 }
64 row {
65 field {
66 type: OPERATOR operator { name: "default" }
67 }
68 field {
69 type: OPERATOR operator { name: "default" }
70 }
71 field {
72 type: OPERATOR operator { name: "default" }
73 }
74 }
75 }
76 -->recvresult
77
78 Mysqlx.Crud.Insert {
79 collection { name: "fault" schema: "xtest"}
80 data_model: TABLE
81 projection {name: "value"}
82 row {
83 field {
84 type: OPERATOR operator { name: "default" }
85 }
86 }
87 }
88 -->recverror 1364
89
90
91 Mysqlx.Crud.Insert {
92 collection { name: "fault" schema: "xtest"}
93 data_model: TABLE
94 projection {name: "value"}
95 row {
96 field {
97 type: OPERATOR operator {
98 name: "default"
99 param {
100 type: LITERAL literal { type: V_SINT v_signed_int: 3 }
101 }
102 }
103 }
104 }
105 }
106 -->recverror 5151
107 EOF
108
109 --exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/crud_insert_default.xpl 2>&1
110
111 SELECT * FROM xtest.table;
112 SELECT * FROM xtest.fault;
113
114 ## Cleanup
115 --source ../include/xplugin_cleanup.inc