polardbxengine/mysql-test/suite/x/t/update_sql_o.test

173 lines
5.0 KiB
Plaintext

########### ../t/update_sql_o.test #####################
### #
### This test runs aims to run UPDATE sql statements #
### variant with mysqlxtest client. #
### Test covers #
### - update with different operators #
### - update on multiple rows #
### #
########################################################################
#
--echo =============================================
--echo SQL UPDATE SCENARIOS
--echo =============================================
--echo
--echo ================================================================================
--echo PREAMBLE
--echo ================================================================================
--replace_regex /\.dll/.so/
--source include/xplugin_preamble.inc
create user user2@localhost identified by 'user2';
grant all on *.* to user2@localhost;
## TEST STARTS HERE
--echo ================================================================================
--echo TEST START
--echo ================================================================================
--write_file $MYSQL_TMP_DIR/mysqlx-update_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);
## Update varchar
UPDATE categories SET CategoryName = 'Sports Update' where CategoryID =1;
## Update Tiny Int value
UPDATE categories SET CategoryIMEI = 110 where CategoryID = 1;
## Update Decimal value
UPDATE categories SET CategoryDecimal = 613.47 where CategoryID =1;
## Corner Values
## Update with Quotes value
UPDATE categories SET
CategoryName='"Quotes"',
CategoryDescription='Quote Categories',
CategoryIMEI = 3,
CategoryDecimal = 235.15
WHERE CategoryID = 3;
## Update with NULL values
UPDATE categories SET
CategoryName=NULL,
CategoryDescription=NULL,
CategoryIMEI = NULL,
CategoryDecimal = NULL
WHERE CategoryID = 4;
## Update with Corner decimal values
UPDATE categories SET CategoryDecimal = 999.99
WHERE CategoryID = 3;
UPDATE categories SET CategoryDecimal = -999.99
WHERE CategoryID = 3;
## Update with Corner tiny int value
UPDATE categories SET CategoryIMEI = 127
WHERE CategoryID = 4;
UPDATE categories SET CategoryIMEI = -128
WHERE CategoryID = 4;
-->endsql
EOF
--exec $MYSQLXTEST -u user2 --password='user2' --file=$MYSQL_TMP_DIR/mysqlx-update_sql.tmp 2>&1
--remove_file $MYSQL_TMP_DIR/mysqlx-update_sql.tmp
--echo .
--echo #---------- START NEGATIVE TEST ----------#
--echo .
## ******************************************
## 2. Negative Test starts here |
## |
## ******************************************
--write_file $MYSQL_TMP_DIR/mysqlx-update_sql_negative.tmp
-->sql
USE mysqlxplugin;
## Negative Testing
## With wrong column name
## Error Code: 1054
-->endsql
-->expecterror 1054
-->sql
UPDATE categories SET CategoryNoExist = 2 where CategoryID =1;
-->endsql
## Correspondence between data and field types
## Error Code: 1366
-->expecterror 1366
-->sql
UPDATE categories set CategoryIMEI = 'TinyInt' WHERE CategoryID = 2;
-->endsql
-->expecterror 1366
-->sql
UPDATE categories set CategoryDecimal = 'Decimal' WHERE CategoryID = 2;
-->endsql
## Data types corner value plus 1
## Error code: 1264
-->expecterror 1264
-->sql
UPDATE categories SET CategoryDecimal = 1000.00 WHERE CategoryID = 3;
-->endsql
-->expecterror 1264
-->sql
UPDATE categories SET CategoryDecimal = -1000.00 WHERE CategoryID = 3;
-->endsql
-->expecterror 1264
-->sql
UPDATE categories SET CategoryIMEI = 128 WHERE CategoryID = 4;
-->endsql
-->expecterror 1264
-->sql
UPDATE categories SET CategoryIMEI = -129 WHERE CategoryID = 4;
-->endsql
## Non existing table
-->expecterror 1146
-->sql
UPDATE categories_no_exist set CategoryIMEI = 'TinyInt' WHERE CategoryID = 2;
-->endsql
## Cleanup
-->echo ================================================================================
-->echo CLEAN UP
-->echo ================================================================================
-->sql
DROP SCHEMA if EXISTS mysqlxplugin;
DROP USER user2@localhost;
-->endsql
EOF
--exec $MYSQLXTEST -u user2 --password='user2' --file=$MYSQL_TMP_DIR/mysqlx-update_sql_negative.tmp 2>&1
## Cleanup
--remove_file $MYSQL_TMP_DIR/mysqlx-update_sql_negative.tmp