Skip to main content
Skip to main content

ASSERT_TRUE

Description​

Syntax​

BOOLEAN assert_true(BOOLEAN condition, VarcharLiteral errmsg)

When condition is true, return true. Otherwise throws an error with message errmsg. errmsg could only be Literal.

Example​

mysql> select assert_true(1, "wrong");
+------------------------------------------+
| assert_true(cast(1 as BOOLEAN), 'wrong') |
+------------------------------------------+
| 1 |
+------------------------------------------+
1 row in set (0.12 sec)

mysql> select assert_true(1, nullable("wrong"));
ERROR 1105 (HY000): errCode = 2, detailMessage = assert_true only accept constant for 2nd argument
mysql> select assert_true(0, "wrong");
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong
mysql> select assert_true(null, "wrong");
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong

Keywords​

ASSERT_TRUE, ASSERT, TRUE