When(Where) does qual become a List ?

Started by Hiroshi Inoueover 26 years ago2 messages
#1Hiroshi Inoue
Inoue@tpf.co.jp

Hello all,

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 ?

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

Are Expr and List compatible ?
I could see such CAST in some places.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hiroshi Inoue (#1)
Re: [HACKERS] When(Where) does qual become a List ?

"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