mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* restrictinfo.c
|
|
* RestrictInfo node manipulation routines.
|
|
*
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
*
|
|
* IDENTIFICATION
|
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.14 2002/06/20 20:29:31 momjian Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#include "postgres.h"
|
|
|
|
|
|
#include "optimizer/clauses.h"
|
|
#include "optimizer/restrictinfo.h"
|
|
|
|
/*
|
|
* restriction_is_or_clause
|
|
*
|
|
* Returns t iff the restrictinfo node contains an 'or' clause.
|
|
*
|
|
*/
|
|
bool
|
|
restriction_is_or_clause(RestrictInfo *restrictinfo)
|
|
{
|
|
if (restrictinfo != NULL &&
|
|
or_clause((Node *) restrictinfo->clause))
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* get_actual_clauses
|
|
*
|
|
* Returns a list containing the clauses from 'restrictinfo_list'.
|
|
*
|
|
*/
|
|
List *
|
|
get_actual_clauses(List *restrictinfo_list)
|
|
{
|
|
List *result = NIL;
|
|
List *temp;
|
|
|
|
foreach(temp, restrictinfo_list)
|
|
{
|
|
RestrictInfo *clause = (RestrictInfo *) lfirst(temp);
|
|
|
|
result = lappend(result, clause->clause);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*
|
|
* get_actual_join_clauses
|
|
*
|
|
* Extract clauses from 'restrictinfo_list', separating those that
|
|
* syntactically match the join level from those that were pushed down.
|
|
*/
|
|
void
|
|
get_actual_join_clauses(List *restrictinfo_list,
|
|
List **joinquals, List **otherquals)
|
|
{
|
|
List *temp;
|
|
|
|
*joinquals = NIL;
|
|
*otherquals = NIL;
|
|
|
|
foreach(temp, restrictinfo_list)
|
|
{
|
|
RestrictInfo *clause = (RestrictInfo *) lfirst(temp);
|
|
|
|
if (clause->ispusheddown)
|
|
*otherquals = lappend(*otherquals, clause->clause);
|
|
else
|
|
*joinquals = lappend(*joinquals, clause->clause);
|
|
}
|
|
}
|