跳到主要内容
跳到主要内容

ASSERT_TRUE

Description

Syntax

BOOLEAN assert_true(BOOLEAN condition, VarcharLiteral errmsg)

conditiontrue 时, 返回 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