config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/x/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/x/t/update_crud_o.test

###########    ../t/update_crud_o.test                     #############
###                                                                    #
### This test runs aims to run UPDATE SET operation statement variant  #
### with mysqlxtest client.                                            #
### Test covers                                                        #
###  - update with safe_update mode(ON/OFF)                            #
###  - update with different operators                                 #
###  - update on multiple rows                                         #
###  - update with data model as table                                 #
###  - update with data model as document                              #
###  - update multiple column                                          #
###  - update using transaction                                        #
###  - update with multiple condition                                  #
###  - Update immutable document member _id (Error expected )          #
###  - Update _id virtual column(possible using data_model:TABLE)      #
###  - status variable Mysqlx_crud_update for number of Update         # 
###    requests received                                               #
###                                                                    #
########################################################################
#

--echo ==============================================
--echo     CRUD UPDATE SCENARIOS
--echo ==============================================
--echo 

## Preamble
--echo ================================================================================
--echo PREAMBLE
--echo ================================================================================
--source ../include/xplugin_preamble.inc
create user updatecruduser@localhost identified by 'updatecruduser';
grant all on *.* to updatecruduser@localhost;

## TEST STARTS HERE
--echo ================================================================================
--echo TEST START
--echo ================================================================================
--write_file $MYSQL_TMP_DIR/mysqlx-update_crud_safemode_1.tmp
-->sql
 DROP SCHEMA if EXISTS mysqlxplugin;
 CREATE SCHEMA mysqlxplugin DEFAULT CHARSET='utf8';
 USE mysqlxplugin;

 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)
 );

 INSERT INTO categories(CategoryID, CategoryName, CategoryDescription, CategoryIMEI, CategoryDecimal,CategoryBool)
 VALUES
 (1,'Sports','Sports related category',1,235.15,true),
 (2,'Entertaiment','Entertaiment related category',2,235.15,false),
 (3, 'Home','Home related category',3,235.15,true),
 (4, 'Kitchen','Kitchen related category',4,235.15,false),
 (5, 'Garden','Garden related category',5,535.15,true),
 (6, 'Toys','Toys related category',6,635.15,false);

 
## SQL safe updates as 1 will allow to update only when you use a key column in the wehere clause
 SET SQL_SAFE_UPDATES = 1;
 
 SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update varchar with where based in key column 
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 1
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryName"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "SportsUpdate"
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID=1;
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update Tiny Int with where based in key column
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 1
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
        type: V_SINT
        v_signed_int: 110
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID=1;
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update Decimal with where based in key column
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 1
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryDecimal"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
        type: V_DOUBLE
        v_double: 613.57
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID in (1,2);
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

## Corner Values
-->echo Update with Quotes value
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 2
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryDescription"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_STRING
       v_string{
       	value: "\"Quotes\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID=2;
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update with NULL value
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 2
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryName"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_NULL
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID in (2,3);
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update with Corner decimal value and != operator
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 2
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryDecimal"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: 999.99
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID != 2;
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update with Corner decimal value and "in" operator
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 3
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryDecimal"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: -999.99
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID in (3,4);
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update with Corner decimal value and != operator
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 2
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: 127
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID != 2;
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql

-->echo Update with Corner decimal value and "in" operator
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 5
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: -128
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.categories where CategoryID in (4,5);
SHOW STATUS like 'Mysqlx_crud_update';
-->endsql


EOF

--exec $MYSQLXTEST -u updatecruduser --password='updatecruduser' --file=$MYSQL_TMP_DIR/mysqlx-update_crud_safemode_1.tmp 2>&1
--remove_file $MYSQL_TMP_DIR/mysqlx-update_crud_safemode_1.tmp

--echo .
--echo #---------- TEST WITH SAFE MODE OFF ----------#
--echo .

## ***************************************
## Start test with safe mode off	         |
##                                        |
## ***************************************

--write_file $MYSQL_TMP_DIR/mysqlx-update_crud_safemode_0.tmp
-->sql
 USE mysqlxplugin;
## SQL safe updates as 0 will allow to update without the need to use a key column 
 SET SQL_SAFE_UPDATES = 0;
-->endsql


-->echo Update with wrong schema name
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "noschemalikethis"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 5
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: 101
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Update with wrong table name
Mysqlx.Crud.Update {
  collection {
    name: "notablelikethis"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 5
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: 101.02
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Update with wrong column name
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT
        identifier {
          name: "nocolumnname"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 5
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: 101
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Update decimal value with a corner value plus 1
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryDecimal"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
        type: V_DOUBLE
        v_double: 1000.00
      }
    }
  }
}
-- Mysqlx.Error
-->expecterror 1264
-->recvresult 

-->echo Update tiny int value with a corner value plus 1
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
        literal {
             type: V_SINT
             v_signed_int: 4
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
      literal {
      	type: V_DOUBLE
      	v_double: -129
      }
    }
  }


}
-- Mysqlx.Error
-->expecterror 1264
-->recvresult 


-->echo Update multiple column
-->sql
select * from mysqlxplugin.categories where CategoryID=4;
-->endsql
Mysqlx.Crud.Update {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryID"
        }
      }
      param {
        type: LITERAL
          literal {
               type: V_SINT
               v_signed_int: 4
        }
      }
    }
  }
  operation {
    source {
      name: "CategoryIMEI"
    }
    operation: SET
    value {
      type: LITERAL
        literal {
                type: V_DOUBLE
                v_double: -99
      }
    }
  }

  operation {
    source {
      name: "CategoryDecimal"
    }
    operation: SET
    value {
      type: LITERAL
        literal {
                type: V_DOUBLE
                v_double: 501.11
        }
    }
  }

}
-->recvresult
-->sql
select * from mysqlxplugin.categories where CategoryID=4;
-->endsql
EOF

--exec $MYSQLXTEST -u updatecruduser --password='updatecruduser' --file=$MYSQL_TMP_DIR/mysqlx-update_crud_safemode_0.tmp 2>&1
--remove_file $MYSQL_TMP_DIR/mysqlx-update_crud_safemode_0.tmp

## ***************************************
## Test with safe mode off for Collection |
##                                        |
## ***************************************

--write_file $MYSQL_TMP_DIR/mysqlx-update_crud_collection_safemode_0.tmp
-->sql
 SET SQL_SAFE_UPDATES = 0;
DROP SCHEMA if EXISTS mysqlxcoll;
CREATE SCHEMA mysqlxcoll;
USE mysqlxcoll;
CREATE TABLE maincoll (doc JSON, _id VARCHAR(32) NOT NULL PRIMARY KEY);
INSERT INTO maincoll (doc, _id) values ('{"_id": "1", "name": "Victor", "last_name": "Otero","amount": 4.99}',json_unquote(json_extract(doc, '$._id')));
INSERT INTO maincoll (doc, _id) values ('{"_id": "2", "name": "Gonzalo", "last_name": "Chrystens","amount": 120.57}',json_unquote(json_extract(doc, '$._id')));
INSERT INTO maincoll (doc, _id) values ('{"_id": "3", "name": "Abraham", "last_name": "Vega","amount": 74.56}',json_unquote(json_extract(doc, '$._id')));
INSERT INTO maincoll (doc, _id) values ('{"_id": "4", "name": "Jennifer", "last_name": "Leon","amount": 387.14}',json_unquote(json_extract(doc, '$._id')));
INSERT INTO maincoll (doc, _id) values ('{"_id": "5", "name": "Jhonny", "last_name": "Test","amount": 125.45}',json_unquote(json_extract(doc, '$._id')));
-->endsql

-->echo Update a valid collection with string value and > operator for multiple docs
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: ">"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"xtest_>\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update a valid collection with string value and > operator for multiple docs
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "<"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"xtest_<\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update a valid collection with string value and <= operator for multiple docs
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "<="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"xtest_<=\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update a valid collection with string value and >= operator for multiple docs
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: ">="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"4"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"xtest_>=\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update a valid collection with string value and != operator for multiple docs
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"2"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "last_name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"xtest_!=\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update order clause update last _id in desc order (_id = 5)
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"0"}
        }
      }
    }
  }
  limit {
    row_count: 1
  }  
  order {
    expr {
      type: IDENT
      identifier {
        name: "_id"
      }
    }
    direction: DESC
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "last_name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"Limit1OrderDesc\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Update with order clause update first two _id in asc order (_id = 1,2)
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"0"}
        }
      }
    }
  }
  limit {
    row_count: 2
  }  
  order {
    expr {
      type: IDENT
      identifier {
        name: "_id"
      }
    }
    direction: ASC
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "last_name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "\"Limit2OrderAsc\""
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from maincoll;
-->endsql

-->echo Invalid type of update for Document
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: ">"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: SET
    value {
      type: LITERAL
      literal {
        type: V_STRING
        v_string {
          value: "xtest"
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->expecterror 5051
-->recvresult



-->echo Update multiple column + transaction
-->sql
START TRANSACTION;
-->endsql
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: ">"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
          literal {
            type: V_OCTETS
            v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_STRING
          v_string {
            value: "name_mul_update_save_a"
          }
        }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "last_name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_STRING
          v_string {
            value: "last_name_mul_update_save_a"
          }
      }
    }
  }
}
-->recvresult
-->sql
SELECT * FROM mysqlxcoll.maincoll where _id > 3;
SAVEPOINT A;
-->endsql
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: ">"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "_id"
          }
        }
      }
      param {
        type: LITERAL
          literal {
            type: V_OCTETS
            v_octets {value:"3"}
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_STRING
          v_string {
            value: "name_mul_update_save_b"
          }
        }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "last_name"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_STRING
          v_string {
            value: "last_name_mul_update_save_b"
          }
      }
    }
  }
}
-->recvresult
-->sql
SELECT * FROM mysqlxcoll.maincoll where _id > 3;
ROLLBACK TO SAVEPOINT A;
COMMIT;
SELECT * FROM mysqlxcoll.maincoll where _id > 3;
-->endsql

-->echo document member _id is immutable
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "last_name"
          }
        }
      }
      param {
        type: LITERAL
          literal {
            type: V_STRING
            v_string {
               value: "Chrystens"
            }
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "_id"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"11"}
        }
    }
  }
}
# Error
-->expecterror 5053
-->recvresult
-->sql
SELECT * FROM mysqlxcoll.maincoll;
-->endsql


-->echo document member _id is immutable but _id column can be updated
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "last_name"
          }
        }
      }
      param {
        type: LITERAL
          literal {
            type: V_STRING
            v_string {
               value: "Chrystens"
            }
          }
      }
    }
  }
  operation {
    source {
        name: "_id"
    }
    operation: SET
    value {
      type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"11"}
        }
    }
  }
}
-->recvresult
-->sql
SELECT * FROM mysqlxcoll.maincoll;
-->endsql
#
-->echo Update using multiple condition
Mysqlx.Crud.Update {
  collection {
    name: "maincoll"
    schema: "mysqlxcoll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: ">="
          param {
             type: IDENT
             identifier {
                document_path {
                   type: MEMBER
                   value: "_id"
                }
             }
           } 
          param {
            type: LITERAL
              literal {
                type: V_SINT
                v_signed_int: 4
              }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: "=="
          param {
            type: IDENT
            identifier {
              name: "_id"
            }
          }
          param {
            type: LITERAL
              literal {
                type: V_SINT
	             v_signed_int: 4
              }
          }
        }
      }
    }
  }
  operation {
    source {
      document_path {
        type: MEMBER
        value: "amount"
      }
    }
    operation: ITEM_SET
    value {
      type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"444"}
      }
    }
  }


}
-->recvresult
-->sql
SELECT * FROM mysqlxcoll.maincoll;
-->endsql

## Cleanup
-->echo ================================================================================
-->echo CLEAN UP
-->echo ================================================================================
-->sql
 DROP SCHEMA if EXISTS mysqlxplugin;
 DROP SCHEMA if EXISTS mysqlxcoll;
 DROP USER updatecruduser@localhost;
 SET SQL_SAFE_UPDATES = 1;
-->endsql
EOF

--exec $MYSQLXTEST -u updatecruduser --password='updatecruduser' --file=$MYSQL_TMP_DIR/mysqlx-update_crud_collection_safemode_0.tmp 2>&1
--remove_file $MYSQL_TMP_DIR/mysqlx-update_crud_collection_safemode_0.tmp

## Postamble
--echo ================================================================================
--echo POSTAMBLE
--echo ================================================================================
uninstall plugin mysqlx;

Man Man