Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

predtest.h File Reference

#include "nodes/primnodes.h"
Include dependency graph for predtest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool predicate_implied_by (List *predicate_list, List *restrictinfo_list)
bool predicate_refuted_by (List *predicate_list, List *restrictinfo_list)

Function Documentation

bool predicate_implied_by ( List predicate_list,
List restrictinfo_list 
)

Definition at line 124 of file predtest.c.

References linitial, list_length(), NIL, and predicate_implied_by_recurse().

Referenced by add_predicate_to_quals(), build_paths_for_OR(), check_partial_indexes(), choose_bitmap_and(), create_bitmap_scan_plan(), create_bitmap_subplan(), create_indexscan_plan(), gincostestimate(), and make_restrictinfo_from_bitmapqual().

{
    Node       *p,
               *r;

    if (predicate_list == NIL)
        return true;            /* no predicate: implication is vacuous */
    if (restrictinfo_list == NIL)
        return false;           /* no restriction: implication must fail */

    /*
     * If either input is a single-element list, replace it with its lone
     * member; this avoids one useless level of AND-recursion.  We only need
     * to worry about this at top level, since eval_const_expressions should
     * have gotten rid of any trivial ANDs or ORs below that.
     */
    if (list_length(predicate_list) == 1)
        p = (Node *) linitial(predicate_list);
    else
        p = (Node *) predicate_list;
    if (list_length(restrictinfo_list) == 1)
        r = (Node *) linitial(restrictinfo_list);
    else
        r = (Node *) restrictinfo_list;

    /* And away we go ... */
    return predicate_implied_by_recurse(r, p);
}

bool predicate_refuted_by ( List predicate_list,
List restrictinfo_list 
)

Definition at line 182 of file predtest.c.

References linitial, list_length(), NIL, and predicate_refuted_by_recurse().

Referenced by relation_excluded_by_constraints().

{
    Node       *p,
               *r;

    if (predicate_list == NIL)
        return false;           /* no predicate: no refutation is possible */
    if (restrictinfo_list == NIL)
        return false;           /* no restriction: refutation must fail */

    /*
     * If either input is a single-element list, replace it with its lone
     * member; this avoids one useless level of AND-recursion.  We only need
     * to worry about this at top level, since eval_const_expressions should
     * have gotten rid of any trivial ANDs or ORs below that.
     */
    if (list_length(predicate_list) == 1)
        p = (Node *) linitial(predicate_list);
    else
        p = (Node *) predicate_list;
    if (list_length(restrictinfo_list) == 1)
        r = (Node *) linitial(restrictinfo_list);
    else
        r = (Node *) restrictinfo_list;

    /* And away we go ... */
    return predicate_refuted_by_recurse(r, p);
}