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/delete_crud_o.test

###########         ../t/delete_crud_o.test                  ###########
###                                                                    #
### This test runs aims to run DELETE operation statements             #
### variant with mysqlxtest client for Table and Document data models. #
### Test covers                                                        #
###  - delete with different operators                                 #
###  - delete multiple rows                                            #
###  - status variable Mysqlx_crud_delete for number of Delete         # 
###    requests received                                               #
###                                                                    #
########################################################################
#

--echo ==============================================
--echo     CRUD DELETE SCENARIOS
--echo ==============================================
--echo 

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

## TEST STARTS HERE
--echo ================================================================================
--echo TEST START
--echo ================================================================================
--write_file $MYSQL_TMP_DIR/mysqlx-delete_sql.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),
 PRIMARY key (CategoryID)
 );

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

 CREATE TABLE extracategoryinfo (
 extracategoryinfoID int NOT NULL AUTO_INCREMENT,
 CategoryID int NOT NULL,
 MainParentCategoryName varchar(100),
 PRIMARY key (extracategoryinfoID)
 );

 INSERT INTO extracategoryinfo(extracategoryinfoID, CategoryID, MainParentCategoryName)
 VALUES
 (1,1,'People'),
 (2,2,'People'),
 (3,2,'House'),
 (4,3,'House'),
 (5,1,'People'),
 (6,2,'People'),
 (7,2,'House'),
 (8,3,'House'),
 (9,1,'People'),
 (10,2,'House');
 
## SQL safe updates as 1 will allow to delete only when you use a key column in the wehere clause
 SET SQL_SAFE_UPDATES = 1;
 SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->sql
select * from mysqlxplugin.extracategoryinfo;

-->endsql

-->echo Delete with In, && operators
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "extracategoryinfoID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 1
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 3
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: "=="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 2
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with == operator
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "extracategoryinfoID"
        }
      }
      param {
        type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 1
            }
         }
      }
   }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Error 1175 expected because of the safe mode = 1
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "MainParentCategoryName"
        }
      }
      param {
        type: LITERAL
            literal {
              type: V_OCTETS
              v_octets {value:"People"}
            }
         }
      }
   }
}
-- Mysqlx.Error
-->recv

-->echo Error 1175 expected because of the safe mode = 1
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "||"
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "MainParentCategoryName"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_OCTETS
              v_octets {value:"House"}
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 4
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Error 1175 expected because of the safe mode = 1
Mysqlx.Crud.Delete {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "CategoryIMEI"
        }
      }
      param {
        type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 1
            }
         }
      }
   }
}
-- Mysqlx.Error
-->recv

-->sql
select * from mysqlxplugin.extracategoryinfo;

-->endsql

EOF

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

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

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

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

-->echo Delete all
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;

-->endsql

-->sql
 INSERT INTO extracategoryinfo(extracategoryinfoID, CategoryID, MainParentCategoryName)
 VALUES
 (1,1,'People'),
 (2,2,'People'),
 (3,2,'House'),
 (4,3,'House'),
 (5,1,'People'),
 (6,2,'People2'),
 (7,2,'House2'),
 (8,3,'House2'),
 (9,9,'People2'),
 (10,10,'House2'),
 (11,11,'House3'),
 (12,12,'House4'),
 (13,13,'House5'),
 (14,14,'House6');
-->endsql

-->sql
select * from mysqlxplugin.extracategoryinfo;

-->endsql

-->echo Delete works ok because of the safe mode = 0
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          name: "MainParentCategoryName"
        }
      }
      param {
        type: LITERAL
            literal {
              type: V_OCTETS
              v_octets {value:"People"}
            }
         }
      }
   }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with || operator and in
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "||"
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "MainParentCategoryName"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_OCTETS
              v_octets {value:"House"}
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 4
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with || operator and not in
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "||"
      param {
        type: OPERATOR
        operator {
          name: "not_in"
          param {
            type: IDENT
            identifier {
              name: "MainParentCategoryName"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_OCTETS
              v_octets {value:"House"}
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: "in"
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 8
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;

select * from mysqlxplugin.categories;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with != operator
Mysqlx.Crud.Delete {
  collection {
    name: "categories"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          name: "CategoryIMEI"
        }
      }
      param {
        type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 1
            }
         }
      }
   }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
 select * from mysqlxplugin.categories;

 select * from mysqlxplugin.extracategoryinfo;

 INSERT INTO extracategoryinfo(extracategoryinfoID, CategoryID, MainParentCategoryName)
 VALUES
 (9,9,'People'),
 (10,10,'People'),
 (11,11,'People'),
 (12,12,'House'),
 (13,13,'House'),
 (14,14,'House');

 select * from mysqlxplugin.extracategoryinfo;
-->endsql

-->echo Delete with > and < operators
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "<"
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 11
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: ">"
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 9
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with >= and <= operators
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "<="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 14
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: ">="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 13
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
select * from mysqlxplugin.extracategoryinfo;
SHOW STATUS like 'Mysqlx_crud_delete';
-->endsql

-->echo Delete with wrong Schema
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "noavailableschema"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "<="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 14
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: ">="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 13
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Delete with wrong Table
Mysqlx.Crud.Delete {
  collection {
    name: "notavailabletable"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "<="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 14
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: ">="
          param {
            type: IDENT
            identifier {
              name: "CategoryID"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 13
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Error
-->recv

-->echo Delete with wrong Column
Mysqlx.Crud.Delete {
  collection {
    name: "extracategoryinfo"
    schema: "mysqlxplugin"
  }
  data_model: TABLE
  criteria {
    type: OPERATOR
    operator {
      name: "&&"
      param {
        type: OPERATOR
        operator {
          name: "<="
          param {
            type: IDENT
            identifier {
              name: "notavailablecolumn"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 14
            }
          }
        }
      }
      param {
        type: OPERATOR
        operator {
          name: ">="
          param {
            type: IDENT
            identifier {
              name: "notavailablecolumn"
            }
          }
          param {
            type: LITERAL
            literal {
              type: V_SINT
              v_signed_int: 13
            }
          }
        }
      }
    }
  }
}
-- Mysqlx.Error
-->recv

EOF

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


## ******************************************
## 3. Delete Collection Statements	         |
##                                           |
## ******************************************

--echo .
--echo #---------- START COLLECTION TESTING----------#
--echo .

--write_file $MYSQL_TMP_DIR/mysqlx-delete_collection_CRUD.tmp
-->sql
DROP SCHEMA if EXISTS mysqlxplugin_coll;
CREATE SCHEMA mysqlxplugin_coll;
USE mysqlxplugin_coll;
CREATE TABLE mysqlxplugin_coll.main_collection (doc JSON, _id VARCHAR(32) NOT NULL PRIMARY KEY);
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "1", "name": "Omar", "Last_Name":"Andrei"}', json_unquote(json_extract(doc, '$._id')));
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "2", "name": "Alfonso", "Last_Name":"Pavluchenko"}', json_unquote(json_extract(doc, '$._id')));
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "3", "name": "Rodrigo", "Last_Name":"Kernel"}', json_unquote(json_extract(doc, '$._id')));
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "4", "name": "Omar", "Last_Name":"Kerball"}', json_unquote(json_extract(doc, '$._id')));
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "5", "name": "Omar", "Last_Name":"Lopez"}', json_unquote(json_extract(doc, '$._id')));
insert into mysqlxplugin_coll.main_collection (doc, _id) values ('{"_id": "6", "name": "Javier", "Last_Name":"Torres"}', json_unquote(json_extract(doc, '$._id')));
select * from mysqlxplugin_coll.main_collection;
-->endsql

-->echo Delete collection rows with in Operator and based in ID
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "mysqlxplugin_coll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "in"
      param {
        type: IDENT identifier { name: "_id" }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"1"}
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"3"}
        }
      }
    }
  }
}

-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
 select * from mysqlxplugin_coll.main_collection;
-->endsql

-->echo Delete collection row with == Operator
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "mysqlxplugin_coll"
  }
  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_OCTETS
          v_octets {value:"Pavluchenko"}
        }
      }
    }
  }
}

-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
 select * from mysqlxplugin_coll.main_collection;
-->endsql

-->echo Delete collection row with != Operator
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "mysqlxplugin_coll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "!="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "name"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"Omar"}
        }
      }
    }
  }
}

-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
 select * from mysqlxplugin_coll.main_collection;
-->endsql

-->echo Delete collection row with not in Operator
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "mysqlxplugin_coll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "not_in"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "Last_Name"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"Lopez"}
        }
      }
    }
  }
}

-- Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->sql
 select * from mysqlxplugin_coll.main_collection;
-->endsql

-->echo Delete collection wrong schema
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "not_available_schema"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "not_in"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "Last_Name"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"Lopez"}
        }
      }
    }
  }
}

-- Mysqlx.Error
-->recv

-->echo Delete collection wrong collection
Mysqlx.Crud.Delete {
  collection {
    name: "not_available_collection"
    schema: "mysqlxplugin_coll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "not_in"
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "Last_Name"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"Lopez"}
        }
      }
    }
  }
}

-- Mysqlx.Error
-->recv

-->echo Delete collection wrong member
Mysqlx.Crud.Delete {
  collection {
    name: "main_collection"
    schema: "mysqlxplugin_coll"
  }
  data_model: DOCUMENT
  criteria {
    type: OPERATOR
    operator {
      name: "=="
      param {
        type: IDENT
        identifier {
          document_path {
            type: MEMBER
            value: "notavailablemember"
          }
        }
      }
      param {
        type: LITERAL
        literal {
          type: V_OCTETS
          v_octets {value:"Lopez"}
        }
      }
    }
  }
}

-- No rows affected
-->recvresult

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

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

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


Man Man