340 lines
5.6 KiB
Plaintext
340 lines
5.6 KiB
Plaintext
## Test of general functionality of prepare statement sql message
|
|
|
|
## Preamble
|
|
--source include/xplugin_preamble.inc
|
|
--source include/xplugin_create_user.inc
|
|
## Test starts here
|
|
|
|
--write_file $MYSQL_TMP_DIR/prep_stmt_sql.xpl
|
|
-->import assert_variable.macro
|
|
-->quiet
|
|
|
|
|
|
-->title =Stmt 1: Prepare malformed stmt
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 1
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'BLA BLA'
|
|
}
|
|
}
|
|
}
|
|
-->recverror ER_PARSE_ERROR
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 1
|
|
|
|
-->title =Stmt 1: Try to execute
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 1
|
|
}
|
|
-->expecterror ER_X_BAD_STATEMENT_ID
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 1
|
|
|
|
-->title =Stmt 1: Try to deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 1
|
|
}
|
|
-->recverror ER_X_BAD_STATEMENT_ID
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 1
|
|
|
|
|
|
|
|
-->title =Stmt 2: Prepare correct stmt (no placeholders)
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 2
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'SELECT * FROM xtest.xtable'
|
|
}
|
|
}
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 2
|
|
|
|
|
|
-->title =Stmt 2: Execute (no params)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 2
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 2
|
|
|
|
|
|
-->title =Stmt 2: Execute (one extra param to ignore)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 2
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "Alice%"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 3
|
|
|
|
|
|
-->title =Stmt 2: Deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 2
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 2
|
|
|
|
|
|
-->title =Stmt 3: Prepare correct stmt (one placeholder)
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 3
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'SELECT * FROM xtest.xtable WHERE phrase LIKE ?'
|
|
}
|
|
}
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 3
|
|
|
|
|
|
-->title =Stmt 3: Try to execute (no params)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 3
|
|
}
|
|
-->expecterror ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 4
|
|
|
|
|
|
-->title =Stmt 3: Execute with param
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 3
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "Alice%"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 5
|
|
|
|
|
|
-->title =Stmt 3: Execute with params (one extra to ignore)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 3
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "Bob%"
|
|
}
|
|
}
|
|
}
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "123"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 6
|
|
|
|
|
|
-->title =Stmt 3: Deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 3
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 3
|
|
|
|
|
|
|
|
-->title =Stmt 4: Prepare correct stmt (insert)
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 4
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'INSERT INTO xtest.xtable (phrase) VALUES(?)'
|
|
}
|
|
}
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 4
|
|
|
|
|
|
-->title =Stmt 4: Execute (one param)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 4
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "Christina has a hamster"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 7
|
|
|
|
-->stmtsql SELECT * FROM xtest.xtable
|
|
-->recvresult
|
|
|
|
|
|
-->title =Stmt 4: Deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 4
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 4
|
|
|
|
|
|
|
|
-->title =Stmt 5: Prepare correct stmt (update)
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 5
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'UPDATE xtest.xtable SET phrase = ? ORDER BY phrase LIMIT 1'
|
|
}
|
|
}
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 5
|
|
|
|
|
|
-->title =Stmt 5: Execute (one param)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 5
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "David has a parot"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 8
|
|
|
|
-->stmtsql SELECT * FROM xtest.xtable
|
|
-->recvresult
|
|
|
|
|
|
-->title =Stmt 5: Deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 5
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 5
|
|
|
|
|
|
|
|
#-----------------------------
|
|
|
|
-->title =Stmt 6: Prepare correct stmt (delete)
|
|
|
|
Mysqlx.Prepare.Prepare {
|
|
stmt_id: 6
|
|
stmt: {
|
|
type: STMT
|
|
stmt_execute: {
|
|
stmt: 'DELETE FROM xtest.xtable WHERE phrase LIKE ?'
|
|
}
|
|
}
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_prepare 6
|
|
|
|
|
|
-->title =Stmt 6: Execute (one param)
|
|
|
|
Mysqlx.Prepare.Execute {
|
|
stmt_id: 6
|
|
args {
|
|
type: SCALAR scalar {
|
|
type: V_STRING v_string {
|
|
value: "Bob%"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-->recvresult
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_execute 9
|
|
|
|
-->stmtsql SELECT * FROM xtest.xtable
|
|
-->recvresult
|
|
|
|
|
|
-->title =Stmt 5: Deallocate
|
|
|
|
Mysqlx.Prepare.Deallocate {
|
|
stmt_id: 6
|
|
}
|
|
-->recvok
|
|
|
|
-->callmacro Assert_status_variable Mysqlx_prep_deallocate 6
|
|
EOF
|
|
|
|
|
|
CREATE SCHEMA IF NOT EXISTS xtest;
|
|
USE xtest;
|
|
CREATE TABLE xtable (phrase VARCHAR(30));
|
|
INSERT INTO xtable (phrase) VALUES ('Alice has a cat');
|
|
INSERT INTO xtable (phrase) VALUES ('Bob has a dog');
|
|
|
|
exec $MYSQLXTEST
|
|
-ux_root --password=''
|
|
--file=$MYSQL_TMP_DIR/prep_stmt_sql.xpl 2>&1;
|
|
|
|
|
|
|
|
## Cleanup
|
|
DROP SCHEMA IF EXISTS xtest;
|
|
--remove_files_wildcard $MYSQL_TMP_DIR *.xpl
|
|
--source include/xplugin_drop_user.inc
|