---------- * exec_stmt_if Evaluate a bool expression and * execute the true or false body * conditionally. * ---------- */
| 2467 | * ---------- |
| 2468 | */ |
| 2469 | static int |
| 2470 | exec_stmt_if(PLpgSQL_execstate *estate, PLpgSQL_stmt_if *stmt) |
| 2471 | { |
| 2472 | bool value; |
| 2473 | bool isnull; |
| 2474 | ListCell *lc; |
| 2475 | |
| 2476 | value = exec_eval_boolean(estate, stmt->cond, &isnull); |
| 2477 | exec_eval_cleanup(estate); |
| 2478 | if (!isnull && value) |
| 2479 | return exec_stmts(estate, stmt->then_body); |
| 2480 | |
| 2481 | foreach(lc, stmt->elsif_list) |
| 2482 | { |
| 2483 | PLpgSQL_if_elsif *elif = (PLpgSQL_if_elsif *) lfirst(lc); |
| 2484 | |
| 2485 | value = exec_eval_boolean(estate, elif->cond, &isnull); |
| 2486 | exec_eval_cleanup(estate); |
| 2487 | if (!isnull && value) |
| 2488 | return exec_stmts(estate, elif->stmts); |
| 2489 | } |
| 2490 | |
| 2491 | return exec_stmts(estate, stmt->else_body); |
| 2492 | } |
| 2493 | |
| 2494 | |
| 2495 | /*----------- |
no test coverage detected