1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* restrictinfo.c
|
1999-02-03 21:15:53 +01:00
|
|
|
* RestrictInfo node manipulation routines.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2002-06-20 22:29:54 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.14 2002/06/20 20:29:31 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "optimizer/clauses.h"
|
1999-02-03 21:15:53 +01:00
|
|
|
#include "optimizer/restrictinfo.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
1999-07-25 01:21:14 +02:00
|
|
|
* restriction_is_or_clause
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-07-25 01:21:14 +02:00
|
|
|
* Returns t iff the restrictinfo node contains an 'or' clause.
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
bool
|
1999-07-25 01:21:14 +02:00
|
|
|
restriction_is_or_clause(RestrictInfo *restrictinfo)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-02-03 21:15:53 +01:00
|
|
|
if (restrictinfo != NULL &&
|
|
|
|
or_clause((Node *) restrictinfo->clause))
|
1998-09-01 05:29:17 +02:00
|
|
|
return true;
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
1998-09-01 05:29:17 +02:00
|
|
|
return false;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* get_actual_clauses
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* Returns a list containing the clauses from 'restrictinfo_list'.
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1998-02-26 05:46:47 +01:00
|
|
|
List *
|
1999-02-03 21:15:53 +01:00
|
|
|
get_actual_clauses(List *restrictinfo_list)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
List *result = NIL;
|
|
|
|
List *temp;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-02-03 21:15:53 +01:00
|
|
|
foreach(temp, restrictinfo_list)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1999-07-26 01:07:26 +02:00
|
|
|
RestrictInfo *clause = (RestrictInfo *) lfirst(temp);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-07-26 01:07:26 +02:00
|
|
|
result = lappend(result, clause->clause);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
2000-09-12 23:07:18 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* get_actual_join_clauses
|
|
|
|
*
|
|
|
|
* Extract clauses from 'restrictinfo_list', separating those that
|
2000-09-29 20:21:41 +02:00
|
|
|
* syntactically match the join level from those that were pushed down.
|
2000-09-12 23:07:18 +02:00
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
if (clause->ispusheddown)
|
2000-09-12 23:07:18 +02:00
|
|
|
*otherquals = lappend(*otherquals, clause->clause);
|
2000-09-29 20:21:41 +02:00
|
|
|
else
|
|
|
|
*joinquals = lappend(*joinquals, clause->clause);
|
2000-09-12 23:07:18 +02:00
|
|
|
}
|
|
|
|
}
|