Fix postgresql_fdw to not remove quals from PlanState.qual even if pgsql_fdw
authorShigeru Hanada <[email protected]>
Fri, 3 Dec 2010 07:58:59 +0000 (16:58 +0900)
committerShigeru Hanada <[email protected]>
Fri, 3 Dec 2010 07:58:59 +0000 (16:58 +0900)
some of quals are evaluated on remote side.  All quals are evaluated
in core executor anytime.

contrib/postgresql_fdw/postgresql_fdw.c

index cd7902df810471fea9d37086410e0d30a2aa5465..9044ab6cad8ec37be5d1867a6bad5f600c2404d9 100644 (file)
@@ -383,8 +383,6 @@ deparseSql(ForeignScanState *scanstate)
     */
    if (scanstate->ss.ps.plan->qual)
    {
-       List       *local_qual = NIL;
-       List       *foreign_qual = NIL;
        List       *foreign_expr = NIL;
        ListCell   *lc;
 
@@ -397,18 +395,8 @@ deparseSql(ForeignScanState *scanstate)
            ExprState      *state = lfirst(lc);
 
            if (is_foreign_qual(state->expr))
-           { foreign_qual = lappend(foreign_qual, state);
                foreign_expr = lappend(foreign_expr, state->expr);
-           }
-           else
-               local_qual = lappend(local_qual, state);
        }
-       /*
-        * XXX: If the remote side is not reliable enough, we can keep the qual
-        * in PlanState as is and evaluate them on local side too.  If so, just
-        * omit replacement below.
-        */
-       scanstate->ss.ps.qual = local_qual;
 
        /*
         * Deparse quals to be evaluated in the foreign server if any.
@@ -421,6 +409,7 @@ deparseSql(ForeignScanState *scanstate)
            node = (Node *) make_ands_explicit(foreign_expr);
            appendStringInfo(&sql, " WHERE %s",
                deparse_expression(node, context, prefix, false));
+
            /*
             * The contents of the list MUST NOT be free-ed because they are
             * referenced from Plan.qual list.