Re: [HACKERS] When(Where) does qual become a List ? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] When(Where) does qual become a List ?
Date
Msg-id 26063.931361303@sss.pgh.pa.us
Whole thread Raw
In response to When(Where) does qual become a List ?  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
List pgsql-hackers
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> I see the following defintion of query_planner() in
> optimizer/planner/planmain.c .

> Plan * query_planner(Query *root,
>                           int command_type,
>                           List *tlist,
>                           List *qual)

> Does this mean that qual is already a List when 
> query_planner () is called ?

No, the declaration is a misnomer.

> But I see the following code in query_planner()
>     qual = cnfify((Expr *) qual, true);

> Are Expr and List compatible ?

They're both pointers to "Node" objects, so the code works, ugly though
it is.  It would probably be better to have both query_planner's qual
and cnfify's argument declared as "Node *", since they aren't
necessarily Expr nodes either (could be Var, Const, etc...)

Most of the planner/optimizer was once Lisp code, where there is only
one data type (effectively Node*), and the translation to C code was a
little sloppy about node types in many places.  There are still a lot of
routines that declare their args to be of a specific type that really
isn't the only kind of node they might be handed.

BTW, I never much liked the fact that cnfify returns a list rather than
an explicit "AND" expression...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Vince Vielhaber
Date:
Subject: History?
Next
From: Michael J Schout
Date:
Subject: Re: [HACKERS] Re: Postgresql 6.5-1 rpms on RedHat 6.0