Beispiel #1
0
def has_rvar(
        stmt: pgast.Query, rvar: pgast.PathRangeVar, *,
        env: context.Environment) -> bool:
    return any(
        rvar in set(stmt.get_rvar_map(flavor).values())
        for flavor in ('normal', 'packed')
    )
Beispiel #2
0
def put_path_rvar_if_not_exists(
        stmt: pgast.Query, path_id: irast.PathId, rvar: pgast.PathRangeVar, *,
        flavor: str='normal',
        aspect: str, env: context.Environment) -> None:
    if (path_id, aspect) not in stmt.get_rvar_map(flavor):
        put_path_rvar(
            stmt, path_id, rvar, aspect=aspect, flavor=flavor, env=env)
Beispiel #3
0
def put_path_rvar(
        stmt: pgast.Query, path_id: irast.PathId, rvar: pgast.PathRangeVar, *,
        flavor: str='normal',
        aspect: str, env: context.Environment) -> None:
    assert isinstance(path_id, irast.PathId)
    stmt.get_rvar_map(flavor)[path_id, aspect] = rvar

    # Normally, masked paths (i.e paths that are only behind a fence below),
    # will not be exposed in a query namespace.  However, when the masked
    # path in the *main* path of a set, it must still be exposed, but no
    # further than the immediate parent query.
    try:
        query = rvar.query
    except NotImplementedError:
        pass
    else:
        if path_id in query.path_id_mask:
            stmt.path_id_mask.add(path_id)