List:Internals« Previous MessageNext Message »
From:Zhixuan Zhu Date:May 11 2009 6:34pm
Subject:RE: How to get all fields used in a select query
View as plain text  
That's exactly what we want. Thank you very much!

Have a great day :)
Zhixuan

-----Original Message-----
From: Kristian Nielsen [mailto:knielsen@stripped] 
Sent: Monday, May 11, 2009 12:15 PM
To: Zhixuan Zhu
Cc: internals@stripped
Subject: Re: How to get all fields used in a select query

"Zhixuan Zhu" <zzhu@stripped> writes:

> So my question is: is there a way to get all the fields (item_fields)
> that are used in the query? They should include select list, where,
> having, group by, order by clause, subquery, and everything. Currently
> we're getting all select columns from select_lex.item_list. We then
> parse select_lex.join->conds to get the where clause columns. After
that
> we get group by, order by, having clause columns by iterate
group_list,
> order_list and having of select_lex. Besides the complexity of this
> solution, we're most concerned that some columns might be left out
> because we still can not interpret all the item types on the cond tree
> (like ref item) and we'll drop whatever we don't understand. We'll
> simply return NULL for the columns we drop. Thus MySQL will give a
wrong
> result based on the NULL columns that it actually expects result back.

Can you use the table->write_set and table->read_set?

Generally, table->read_set gives you the columns that you need to fetch
and
return to the SQL layer, and table->write_set gives the columns that you
must
change.

(for write_row(), you need to change all columns always, as this
implements
REPLACE INTO, write_set just gives which columns are mentioned in the
query,
but remaining columns must still be reset to default values).

 - Kristian.
Thread
How to get all fields used in a select queryZhixuan Zhu11 May
  • Re: How to get all fields used in a select queryKristian Nielsen11 May
    • RE: How to get all fields used in a select queryZhixuan Zhu11 May