diff --git a/src/gausskernel/optimizer/path/allpaths.cpp b/src/gausskernel/optimizer/path/allpaths.cpp old mode 100755 new mode 100644 index 8b768d2af..7dd5d454b --- a/src/gausskernel/optimizer/path/allpaths.cpp +++ b/src/gausskernel/optimizer/path/allpaths.cpp @@ -111,24 +111,31 @@ static void bitmap_path_walker(Path* path); static bool check_func_walker(Node* node, bool* found) { + // If the current node is NULL, it cannot be a function expression. if (node == NULL) { return false; - } else if (IsA(node, FuncExpr)) { + } + // If the current node is a function expression (FuncExpr), set 'found' to true and return true. + else if (IsA(node, FuncExpr)) { *found = true; return true; } + // Recursively call the expression_tree_walker function on the current node. + // This function checks child nodes for function expressions. return expression_tree_walker(node, (bool (*)())check_func_walker, found); } /* - * @Description: Check this node if vartype > FirstNormalObjectId. - * @in qual: Checked node. + * @Description: Check if a given node contains a function expression. + * @in qual: The node to be checked. + * @return: True if a function expression is found, otherwise false. */ static bool check_func(Node* node) { bool found = false; + // Call the check_func_walker function to search for function expressions in 'node'. (void)check_func_walker(node, &found); return found; @@ -136,45 +143,59 @@ static bool check_func(Node* node) /* * qual_pushdown_in_partialpush: - * check when qual can push when in partialpush scenario - * Paramters: - * @in query: the father query in partialpush scenario - * @in subquery: the subquery in partialpush scenario - * @in qualclause: the qual clause in father query need be checked + * Check if a given qual clause can be pushed down in a partial push scenario. + * Parameters: + * @in query: The father query in the partial push scenario. + * @in subquery: The subquery in the partial push scenario. + * @in qualclause: The qual clause in the father query that needs to be checked. + * @return: True if the qual clause can be pushed down, otherwise false. */ static bool qual_pushdown_in_partialpush(Query *query, Query *subquery, Node *qualclause) { + // Check if the father query cannot be pushed down, but the subquery can be. if (!query->can_push && subquery->can_push) { shipping_context context; stream_walker_context_init(&context); - (void) stream_walker((Node*)qualclause, (void*)(&context)); + // Call the stream_walker function to analyze the qual clause for pushdown. + (void)stream_walker((Node*)qualclause, (void*)(&context)); + + // Return whether the qual clause is shippable in the given context. return context.current_shippable; } + // If the father query can be pushed down or the subquery cannot be, return true. return true; } /* * updateRelOptInfoMinSecurity: - * update baserestrict_min_security for RelOptInfo rel - * Paramters: - * @in rel: Per-relation information for planning/optimization - * @out void + * Update the baserestrict_min_security field for a RelOptInfo object. + * Parameters: + * @in rel: Per-relation information for planning/optimization. */ static inline void updateRelOptInfoMinSecurity(RelOptInfo* rel) { + // Ensure that the input 'rel' is not NULL. Assert(rel != NULL); + + // Initialize baserestrict_min_security to a maximum value. rel->baserestrict_min_security = UINT_MAX; + ListCell* lc = NULL; RestrictInfo* info = NULL; + + // Iterate over the list of baserestrictinfo and find the minimum security level. foreach (lc, rel->baserestrictinfo) { info = (RestrictInfo*)lfirst(lc); + + // Update baserestrict_min_security if the current security level is smaller. if (info->security_level < rel->baserestrict_min_security) { rel->baserestrict_min_security = info->security_level; } } } + /* * make_one_rel * Finds all possible access paths for executing a query, returning a