* raw_expression_tree_walker --- walk raw parse trees * * This has exactly the same API as expression_tree_walker, but instead of * walking post-analysis parse trees, it knows how to walk the node types * found in raw grammar output. (There is not currently any need for a * combined walker, so we keep them separate in the name of efficiency.) * Unlike expression_tree_walker, there is no spe
| 3823 | * appear in CTEs. |
| 3824 | */ |
| 3825 | bool |
| 3826 | raw_expression_tree_walker(Node *node, |
| 3827 | bool (*walker) (), |
| 3828 | void *context) |
| 3829 | { |
| 3830 | ListCell *temp; |
| 3831 | |
| 3832 | /* |
| 3833 | * The walker has already visited the current node, and so we need only |
| 3834 | * recurse into any sub-nodes it has. |
| 3835 | */ |
| 3836 | if (node == NULL) |
| 3837 | return false; |
| 3838 | |
| 3839 | /* Guard against stack overflow due to overly complex expressions */ |
| 3840 | check_stack_depth(); |
| 3841 | |
| 3842 | switch (nodeTag(node)) |
| 3843 | { |
| 3844 | case T_SetToDefault: |
| 3845 | case T_CurrentOfExpr: |
| 3846 | case T_SQLValueFunction: |
| 3847 | case T_Integer: |
| 3848 | case T_Float: |
| 3849 | case T_String: |
| 3850 | case T_BitString: |
| 3851 | case T_Null: |
| 3852 | case T_ParamRef: |
| 3853 | case T_A_Const: |
| 3854 | case T_A_Star: |
| 3855 | /* primitive node types with no subnodes */ |
| 3856 | break; |
| 3857 | case T_Alias: |
| 3858 | /* we assume the colnames list isn't interesting */ |
| 3859 | break; |
| 3860 | case T_RangeVar: |
| 3861 | return walker(((RangeVar *) node)->alias, context); |
| 3862 | case T_GroupingFunc: |
| 3863 | return walker(((GroupingFunc *) node)->args, context); |
| 3864 | case T_GroupId: |
| 3865 | case T_GroupingSetId: |
| 3866 | break; |
| 3867 | case T_SubLink: |
| 3868 | { |
| 3869 | SubLink *sublink = (SubLink *) node; |
| 3870 | |
| 3871 | if (walker(sublink->testexpr, context)) |
| 3872 | return true; |
| 3873 | /* we assume the operName is not interesting */ |
| 3874 | if (walker(sublink->subselect, context)) |
| 3875 | return true; |
| 3876 | } |
| 3877 | break; |
| 3878 | case T_CaseExpr: |
| 3879 | { |
| 3880 | CaseExpr *caseexpr = (CaseExpr *) node; |
| 3881 | |
| 3882 | if (walker(caseexpr->arg, context)) |