zoukankan      html  css  js  c++  java
  • PostgreSQL在何处处理 sql查询之十五

    如此:

    接前面,看 add_base_rels_to_query函数:

    /*
     * add_base_rels_to_query
     *
     *      Scan the query's jointree and create baserel RelOptInfos for all
     *      the base relations (ie, table, subquery, and function RTEs)
     *      appearing in the jointree.
     *
     * The initial invocation must pass root->parse->jointree as the value of
     * jtnode.    Internally, the function recurses through the jointree.
     *
     * At the end of this process, there should be one baserel RelOptInfo for
     * every non-join RTE that is used in the query.  Therefore, this routine
     * is the only place that should call build_simple_rel with reloptkind
     * RELOPT_BASEREL.    (Note: build_simple_rel recurses internally to build
     * "other rel" RelOptInfos for the members of any appendrels we find here.)
     */
    void
    add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
    {
        if (jtnode == NULL)
            return;
        if (IsA(jtnode, RangeTblRef))
        {
            int            varno = ((RangeTblRef *) jtnode)->rtindex;
    
            (void) build_simple_rel(root, varno, RELOPT_BASEREL);
        }
        else if (IsA(jtnode, FromExpr))
        {
            FromExpr   *f = (FromExpr *) jtnode;
            ListCell   *l;
    
            foreach(l, f->fromlist)
                add_base_rels_to_query(root, lfirst(l));
        }
        else if (IsA(jtnode, JoinExpr))
        {
            JoinExpr   *j = (JoinExpr *) jtnode;
    
            add_base_rels_to_query(root, j->larg);
            add_base_rels_to_query(root, j->rarg);
        }
        else
            elog(ERROR, "unrecognized node type: %d",
                 (int) nodeTag(jtnode));
    }

    如果表所对应的文件出现问题,会在 build_simple_rel处报错。

  • 相关阅读:
    python025 Python3 正则表达式
    python024 Python3 实例
    python023 Python3 标准库概览
    python022 Python3 面向对象
    python021 Python3 错误和异常
    列表和元组的元素不可被修改,但列表和元组的元素的元素可以被修改
    织梦标签
    自动添加QQ
    php把时间存入数据库为年月日时分秒类型
    PHP后台批量删除数据
  • 原文地址:https://www.cnblogs.com/gaojian/p/3094890.html
Copyright © 2011-2022 走看看