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

Function get_view_query

src/backend/rewrite/rewriteHandler.c:2507–2530  ·  view source on GitHub ↗

* get_view_query - get the Query from a view's _RETURN rule. * * Caller should have verified that the relation is a view, and therefore * we should find an ON SELECT action. * * Note that the pointer returned is into the relcache and therefore must * be treated as read-only to the caller and not modified or scribbled on. */

Source from the content-addressed store, hash-verified

2505 * be treated as read-only to the caller and not modified or scribbled on.
2506 */
2507Query *
2508get_view_query(Relation view)
2509{
2510 int i;
2511
2512 Assert(view->rd_rel->relkind == RELKIND_VIEW);
2513
2514 for (i = 0; i < view->rd_rules->numLocks; i++)
2515 {
2516 RewriteRule *rule = view->rd_rules->rules[i];
2517
2518 if (rule->event == CMD_SELECT)
2519 {
2520 /* A _RETURN rule should have only one action */
2521 if (list_length(rule->actions) != 1)
2522 elog(ERROR, "invalid _RETURN rule action specification");
2523
2524 return (Query *) linitial(rule->actions);
2525 }
2526 }
2527
2528 elog(ERROR, "failed to find _RETURN rule for view");
2529 return NULL; /* keep compiler quiet */
2530}
2531
2532
2533/*

Callers 4

relation_is_updatableFunction · 0.85
rewriteTargetViewFunction · 0.85
LockViewRecurseFunction · 0.85
ATExecSetRelOptionsFunction · 0.85

Calls 1

list_lengthFunction · 0.85

Tested by

no test coverage detected