Description
Syntax
BOOLEAN assert_true(BOOLEAN condition, VarcharLiteral errmsg)
当 condition
为 true
时, 返回 true
. 否则抛出一个异常,异常信息为 errmsg
.
errmsg
必须为字面量。
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