polardbxengine/mysql-test/suite/x/r/insert_crud_o.result

1486 lines
26 KiB
Plaintext

==============================================
CRUD INSERT SCENARIOS
==============================================
================================================================================
PREAMBLE
================================================================================
create user insertcruduser@localhost identified by 'insertcruduser';
grant all on *.* to insertcruduser@localhost;
================================================================================
TEST START
================================================================================
RUN DROP SCHEMA if EXISTS mysqlxplugin
0 rows affected
RUN CREATE SCHEMA mysqlxplugin DEFAULT CHARSET='utf8'
1 rows affected
RUN USE mysqlxplugin
0 rows affected
RUN CREATE TABLE categories (
CategoryID int NOT NULL AUTO_INCREMENT,
CategoryName varchar(100),
CategoryDescription varchar(200),
CategoryIMEI tinyint,
CategoryDecimal decimal(5,2),
CategoryBool bit(1),
PRIMARY key (CategoryID)
)
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 0
0 rows affected
Insert multiple rows
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 1
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Sports"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Sports related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 1
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 235.15
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 2
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Entertaiment"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Entertaiment related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 2
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 156.17
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: true
}
}
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 18
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Cooking"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Cooking related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 18
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 116.17
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: true
}
}
}
}
3 rows affected
last insert id: 18
Records: 3 Duplicates: 0 Warnings: 0
RUN select * from categories
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
18 Cooking Cooking related category 18 116.17 1
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 1
0 rows affected
Insert Quotes with scape character
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 3
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "\"Quotes\""
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Quote related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 3
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 184.25
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
1 rows affected
last insert id: 3
RUN select * from categories
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
3 "Quotes" Quote related category 3 184.25 0
18 Cooking Cooking related category 18 116.17 1
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 2
0 rows affected
Insert NULL values
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_NULL
}
}
field {
type: LITERAL
literal {
type: V_NULL
}
}
field {
type: LITERAL
literal {
type: V_NULL
}
}
field {
type: LITERAL
literal {
type: V_NULL
}
}
field {
type: LITERAL
literal {
type: V_NULL
}
}
field {
type: LITERAL
literal {
type: V_NULL
}
}
}
}
1 rows affected
last insert id: 19
RUN select * from categories
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
3 "Quotes" Quote related category 3 184.25 0
18 Cooking Cooking related category 18 116.17 1
19 null null null null null
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 3
0 rows affected
Insert Corner decimal value
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 6
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen2"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen2 related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 6
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 999.99
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: true
}
}
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 12
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 12
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: -999.99
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
2 rows affected
last insert id: 12
Records: 2 Duplicates: 0 Warnings: 0
RUN select * from categories
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
3 "Quotes" Quote related category 3 184.25 0
6 Kitchen2 Kitchen2 related category 6 999.99 1
12 Kitchen Kitchen related category 12 -999.99 0
18 Cooking Cooking related category 18 116.17 1
19 null null null null null
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 4
0 rows affected
Insert Corner tiny int value
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 13
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 127
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 156.99
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 14
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: -128
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 156.99
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
2 rows affected
last insert id: 14
Records: 2 Duplicates: 0 Warnings: 0
RUN select * from categories
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
3 "Quotes" Quote related category 3 184.25 0
6 Kitchen2 Kitchen2 related category 6 999.99 1
12 Kitchen Kitchen related category 12 -999.99 0
13 Kitchen Kitchen related category 127 156.99 0
14 Kitchen Kitchen related category -128 156.99 0
18 Cooking Cooking related category 18 116.17 1
19 null null null null null
0 rows affected
RUN SHOW STATUS like 'Mysqlx_crud_insert'
Variable_name Value
Mysqlx_crud_insert 5
0 rows affected
Mysqlx.Ok {
msg: "bye!"
}
ok
.
#---------- START NEGATIVE TABLE TESTING----------#
.
RUN USE mysqlxplugin
0 rows affected
Repeat key column ID
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 1
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Home"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Home related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 1
}
}
field {
type: LITERAL
literal {
type: V_FLOAT
v_float: 235.15
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Duplicate entry '1' for key 'PRIMARY' (code 1062)
Data types corner value plus 1
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 1000
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 128
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 125.35
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Out of range value for column 'CategoryDecimal' at row 1 (code 1264)
String value in tiny int data type column
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "TinyInt"
}
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 235.15
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Incorrect integer value: 'TinyInt' for column 'CategoryIMEI' at row 1 (code 1366)
String value in decimal data type column
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Decimal"
}
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Incorrect decimal value: 'Decimal' for column 'CategoryDecimal' at row 1 (code 1366)
Invalid Schema name
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "schema_no_exist"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 256.54
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Unknown database 'schema_no_exist' (code 1049)
Invalid Table name
send Mysqlx.Crud.Insert {
collection {
name: "table_no_exist"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "NoIntValue"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 256.54
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Table 'mysqlxplugin.table_no_exist' doesn't exist (code 1146)
Invalid Column name
send Mysqlx.Crud.Insert {
collection {
name: "categories_no_exist"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "ColumnNoExist"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 5
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "NotADouble"
}
}
}
field {
type: LITERAL
literal {
type: V_BOOL
v_bool: false
}
}
}
}
Got expected error: Table 'mysqlxplugin.categories_no_exist' doesn't exist (code 1146)
send Mysqlx.Crud.Insert {
collection {
name: "categories"
schema: "mysqlxplugin"
}
data_model: TABLE
projection {
name: "CategoryID"
}
projection {
name: "CategoryName"
}
projection {
name: "CategoryDescription"
}
projection {
name: "CategoryIMEI"
}
projection {
name: "CategoryDecimal"
}
projection {
name: "CategoryBool"
}
row {
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 16
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen"
}
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "Kitchen related category"
}
}
}
field {
type: LITERAL
literal {
type: V_SINT
v_signed_int: 4
}
}
field {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 235.65
}
}
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "NotAboolValue"
}
}
}
}
}
Got expected error: Data too long for column 'CategoryBool' at row 1 (code 1406)
RUN select * from categories order by CategoryID asc
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal CategoryBool
1 Sports Sports related category 1 235.15 0
2 Entertaiment Entertaiment related category 2 156.17 1
3 "Quotes" Quote related category 3 184.25 0
6 Kitchen2 Kitchen2 related category 6 999.99 1
12 Kitchen Kitchen related category 12 -999.99 0
13 Kitchen Kitchen related category 127 156.99 0
14 Kitchen Kitchen related category -128 156.99 0
18 Cooking Cooking related category 18 116.17 1
19 null null null null null
0 rows affected
Mysqlx.Ok {
msg: "bye!"
}
ok
.
#---------- START COLLECTION TESTING----------#
.
RUN CREATE SCHEMA mysqlxplugin_coll
1 rows affected
RUN USE mysqlxplugin_coll
0 rows affected
command ok
Insert a row into a Document column
send Mysqlx.Crud.Insert {
collection {
name: "main_collection"
schema: "mysqlxplugin_coll"
}
data_model: DOCUMENT
row {
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Port\", \"id\": \"1\"\n}"
}
}
}
}
}
1 rows affected
RUN select * from main_collection
doc _id
{"id": "1", "_id": "1", "name": "Omar Port"} 1
0 rows affected
Insert multiple rows into a Document column
send Mysqlx.Crud.Insert {
collection {
name: "main_collection"
schema: "mysqlxplugin_coll"
}
data_model: DOCUMENT
row {
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Bras\", \"id\": \"2\"\n}"
}
}
}
}
row {
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "\n{\n \"_id\": \"3\",\n \"name\": \"Omar Mex\", \"id\": \"3\"\n}"
}
}
}
}
}
2 rows affected
Records: 2 Duplicates: 0 Warnings: 0
RUN select * from main_collection
doc _id
{"id": "1", "_id": "1", "name": "Omar Port"} 1
{"id": "2", "_id": "2", "name": "Omar Bras"} 2
{"id": "3", "_id": "3", "name": "Omar Mex"} 3
0 rows affected
Insert malformed JSON into Document column
send Mysqlx.Crud.Insert {
collection {
name: "main_collection"
schema: "mysqlxplugin_coll"
}
data_model: DOCUMENT
row {
field {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "\n{\n \"_id\": \"1\",\n \"from\": {\n \"name\": \"Omar Alf\", \"id\": \"10\"\n }\n {\n \"name\": \"Omar Mend\", \"id\": \"11\"\n }\n}"
}
}
}
}
}
Got expected error: Invalid JSON text: "Missing a comma or '}' after an object member." at position 98 in value for column 'main_collection.doc'. (code 3140)
================================================================================
CLEAN UP
================================================================================
RUN SELECT * FROM main_collection
doc _id
{"id": "1", "_id": "1", "name": "Omar Port"} 1
{"id": "2", "_id": "2", "name": "Omar Bras"} 2
{"id": "3", "_id": "3", "name": "Omar Mex"} 3
0 rows affected
RUN DROP SCHEMA if EXISTS mysqlxplugin
1 rows affected
RUN DROP SCHEMA if EXISTS mysqlxplugin_coll
1 rows affected
RUN DROP USER insertcruduser@localhost
0 rows affected
Mysqlx.Ok {
msg: "bye!"
}
ok