Bug #87005 Impossible to close the NO_ERROR expectation
Submitted: 11 Jul 2017 7:08 Modified: 15 Aug 2017 11:00
Reporter: Bogdan Degtyariov Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Document Store: X Plugin Severity:S3 (Non-critical)
Version:5.7.20 OS:Any
Assigned to: CPU Architecture:Any
Tags: xplugin

[11 Jul 2017 7:08] Bogdan Degtyariov
Description:
After setting NO_ERROR expectation block the xplugin does not allow closing it if an error was detected inside the block in one of previous statements.
Instead of closing the expect block it throws the error.

It goes like this:

Mysqlx.Expect::Open([+no_error])
Mysqlx.PreparedStmt::Execute(stmt_id=1) // Valid STMT - OK
Mysqlx.PreparedStmt::Execute(stmt_id=2) // Invalid STMT - Syntax Error
Mysqlx.PreparedStmt::Execute(stmt_id=3) // Valid STMT - Expecation failed Error
Mysqlx.Expect::Close()                  // Valid command - Expecation failed Error

How to repeat:
The X protocol data flow is as this:

>>>> Sending message >>>>
of type 24: Mysqlx::Expect::Open
op: EXPECT_CTX_COPY_PREV
cond {
  condition_key: 1
  op: EXPECT_OP_SET
}
>>>>

<<<< Received message <<<<
of type 0: Mysqlx::Ok
<<<<

>>>> Sending message >>>>
of type 12: Mysqlx::Sql::StmtExecute
stmt: "SELECT 1"
namespace: "sql"
>>>>

<<<< Received message <<<<
of type 12: Mysqlx::Resultset::ColumnMetaData
type: SINT
name: "1"
original_name: ""
table: ""
original_table: ""
schema: ""
catalog: "def"
collation: 0
fractional_digits: 0
length: 1
flags: 16
<<<<

<<<< Received message <<<<
of type 13: Mysqlx::Resultset::Row
field: "\002"
<<<<

<<<< Received message <<<<
of type 14: Mysqlx::Resultset::FetchDone
<<<<

<<<< Received message <<<<
of type 11: Mysqlx::Notice::Frame
type: 3
scope: LOCAL
payload: "\010\004\022\004\010\002\030\000"
<<<<

<<<< Received message <<<<
of type 17: Mysqlx::Sql::StmtExecuteOk
<<<<

>>>> Sending message >>>>
of type 12: Mysqlx::Sql::StmtExecute
stmt: "ERROR SQL"
namespace: "sql"
>>>>

<<<< Received message <<<<
of type 1: Mysqlx::Error
severity: ERROR
code: 1064
msg: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'ERROR SQL\' at line 1"
sql_state: "42000"
<<<<

>>>> Sending message >>>>
of type 12: Mysqlx::Sql::StmtExecute
stmt: "SELECT 2"
namespace: "sql"
>>>>

<<<< Received message <<<<
of type 1: Mysqlx::Error
severity: ERROR
code: 5159
msg: "Expectation failed: no_error"
sql_state: "HY000"
<<<<

>>>> Sending message >>>>
of type 25: Mysqlx::Expect::Close
>>>>

<<<< Received message <<<<
of type 1: Mysqlx::Error
severity: ERROR
code: 5159
msg: "Expectation failed: no_error"
sql_state: "HY000"
<<<<
[15 Aug 2017 11:00] Erlend Dahl
Posted by developer: 

[14 Jul 2017 4:05] Lukasz Kotula

The error is expected behavior.
Successful closure of expectation block is marked with
Mysqlx.Ok or Mysqlx.Error(code=ER_X_EXPECT_NO_ERROR_FAILED) message.