Description

Syntax

BOOLEAN assert_true(BOOLEAN condition, VarcharLiteral errmsg)

conditiontrue 时, 返回 true. 否则抛出一个异常,异常信息为 errmsg. errmsg 必须为字面量。

Example

  1. mysql> select assert_true(1, "wrong");
  2. +------------------------------------------+
  3. | assert_true(cast(1 as BOOLEAN), 'wrong') |
  4. +------------------------------------------+
  5. | 1 |
  6. +------------------------------------------+
  7. 1 row in set (0.12 sec)
  8. mysql> select assert_true(1, nullable("wrong"));
  9. ERROR 1105 (HY000): errCode = 2, detailMessage = assert_true only accept constant for 2nd argument
  10. mysql> select assert_true(0, "wrong");
  11. ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong
  12. mysql> select assert_true(null, "wrong");
  13. ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong

Keywords

  1. ASSERT_TRUE, ASSERT, TRUE