MCPcopy Create free account
hub / github.com/apache/cloudberry / exec_stmt_if

Function exec_stmt_if

src/pl/plpgsql/src/pl_exec.c:2469–2492  ·  view source on GitHub ↗

---------- * exec_stmt_if Evaluate a bool expression and * execute the true or false body * conditionally. * ---------- */

Source from the content-addressed store, hash-verified

2467 * ----------
2468 */
2469static int
2470exec_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/*-----------

Callers 1

exec_stmtsFunction · 0.85

Calls 4

exec_eval_booleanFunction · 0.85
exec_eval_cleanupFunction · 0.85
exec_stmtsFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected