printing restrict clauses

From: "Hossein S(dot) Attar" <hossein_s_attar(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: printing restrict clauses
Date: 2005-11-18 17:29:25
Message-ID: 20051118172926.85442.qmail@web88104.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi:

I have a problem with printing expression. For a
course project, I'm changing postgres optimizer. My
problem is that at some point, I need to print the
restrict caluses of a sequential scan. I get the list
of restrict clauses and for each RestructInfo, I call
print_expr(Node *expr, List *rtable) [defined in
print.c] as follows:

....
RestrictInfo *c = lfirst(l);
print_expr((Node *) c->clause, root->rtable);

The code works well for all clauses except for the
ones that deal with a char column (e.g., SELECT ....
WHERE name = 'abc'). For the latter type of clauses,
the printed string is something like
"unknown expr = 'abc'"
In other words, the column name is not printed
correctly.

I traced the code and it seems that the problem is
that for a clause on a non-string column, the cluase
is represented by 3 nodes of the followiing types
T_OpExpr, T_Var, T_Const (e.g: =,part_id,2)

But for clauses on string columns, the caluse is
stored as 3 nodes of these types:
T_RelabelType, T_Var, T_Const

print_expr() does not knwo how to deal with
T_RelabelType, nodes.

Does anyone know why string columns are represented
differently and how can I make print_expr() work? Is
there another easier way to print restrict clauses?
(Note that I don't want ot call explain or similar
commands to print everything for me. I need to be able
to print single restrict caluses given the Path,
RelOptInfo, and Query structs).

Thanks a lot,
Hossein Attar



__________________________________________________________
Find your next car at http://autos.yahoo.ca

Browse pgsql-general by date

  From Date Subject
Next Message Michelle Konzack 2005-11-18 17:53:08 Re: 3 x PostgreSQL in cluster/redunant
Previous Message Jaime Casanova 2005-11-18 17:27:52 Re: shorter way to get new value of serial?