Merge lp://qastaging/~sinha/drizzle/trunk-bug-621856 into lp://qastaging/drizzle/7.0

Proposed by Akash Sinha
Status: Superseded
Proposed branch: lp://qastaging/~sinha/drizzle/trunk-bug-621856
Merge into: lp://qastaging/drizzle/7.0
Diff against target: 213 lines (+49/-50)
2 files modified
drizzled/cursor.h (+46/-47)
drizzled/sql_parse.cc (+3/-3)
To merge this branch: bzr merge lp://qastaging/~sinha/drizzle/trunk-bug-621856
Reviewer Review Type Date Requested Status
Stewart Smith (community) Disapprove
Vijay Samuel Needs Fixing
David Shrewsbury Pending
Review via email: mp+52931@code.qastaging.launchpad.net

This proposal has been superseded by a proposal from 2011-03-15.

Description of the change

Using regex ,found bunch of functions with unused params in sql_parse.cc file and cursor.h file .
If the changes are fine,then i will start doing the same for rest of the files in drizzled directory.

To post a comment you must log in.
Revision history for this message
Vijay Samuel (vjsamuel) wrote :

Hi Akash,
 Good to see you submitting your first branch. Great job. There are coding standard violations in your branch. Please make it a point to adhere to all the coding guidelines inn the wiki page that I gave you.

I ll just point out some of the obvious one that I could see,
1) assignment operations should be as follows,
   a= b; one space after the = and nonee before.

2) use two space indentations for new blocks of code.

3) braces must be written in new lines.

Please make it a point to fix all the above mentioned and re submit your merge proposal.

Cheers,
 -Vijay

review: Needs Fixing
Revision history for this message
Stewart Smith (stewart) wrote :

On Thu, 10 Mar 2011 21:57:07 -0000, Akash Sinha <email address hidden> wrote:
> --- drizzled/cursor.h 2011-03-07 12:31:41 +0000
> +++ drizzled/cursor.h 2011-03-10 21:44:21 +0000
> @@ -319,12 +319,12 @@
> virtual ha_rows estimate_rows_upper_bound()
> { return stats.records+EXTRA_RECORDS; }
>
> - virtual const char *index_type(uint32_t)
> + virtual const char *index_type()
> { assert(0); return "";}

It looks like index_type() is completely unused (apart from being implemented
in every storage engine) - so instead of just removing the parameter
(which shouldn't always be unused anyway) we should remove all the
implementations of it too.

> @@ -349,15 +349,15 @@
> const unsigned char * key,
> key_part_map keypart_map,
> enum ha_rkey_function find_flag);
> - virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))
> - { return HA_ERR_WRONG_COMMAND; }
> - virtual int index_prev(unsigned char *)
> - { return HA_ERR_WRONG_COMMAND; }
> - virtual int index_first(unsigned char *)
> - { return HA_ERR_WRONG_COMMAND; }
> - virtual int index_last(unsigned char *)
> - { return HA_ERR_WRONG_COMMAND; }
> - virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);
> + virtual int index_next() __attribute__ ((warn_unused_result))
> + { return HA_ERR_WRONG_COMMAND; }
> + virtual int index_prev()
> + { return HA_ERR_WRONG_COMMAND; }
> + virtual int index_first()
> + { return HA_ERR_WRONG_COMMAND; }
> + virtual int index_last()
> + { return HA_ERR_WRONG_COMMAND; }
> + virtual int index_next_same();

This is incorrect, the buffer being passed in is important and at least
*should* be used by classes implementing them.

> private:
> uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);
> @@ -379,20 +379,20 @@
> bool eq_range, bool sorted);
> virtual int read_range_next();
> int compare_key(key_range *range);
> - virtual int rnd_next(unsigned char *)=0;
> - virtual int rnd_pos(unsigned char *, unsigned char *)=0;
> + virtual int rnd_next()=0;
> + virtual int rnd_pos()=0;

the rnd_pos() method is used and does use the parameters (just not in
the default implementation that does nothing), same with rnd_next() -
that is used.

> virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
> - virtual int rnd_same(unsigned char *, uint32_t)
> + virtual int rnd_same()
> { return HA_ERR_WRONG_COMMAND; }
> - virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)
> + virtual ha_rows records_in_range()
> { return (ha_rows) 10; }

also wrong, these parameters are used by all classes that implement it.

So most of this patch isn't quite right (especially around
Cursor). However, there are some unused bit sthat can work. I'd
recommend starting from scratch on a tree and doing these bits

I'd also be sure to when checking out any virtual function to check
everywhere that calls it as well as everywhere that implements it.

--
Stewart Smith

Revision history for this message
Stewart Smith (stewart) :
review: Disapprove
Revision history for this message
Akash Sinha (sinha) wrote :
Download full text (3.7 KiB)

How would i find out exactly from which functions i have to remove
unused params.And moreover i could i say which function is completely
unused.

And also after removing the unused params i ran the "python
tests/dbqp.py" and it didnt return anything wrong.So in case of
virtual functions should i have to go through the entire list of class
functions to check whether that param is being used or not.

Please suggest some better method of doing this.

Akash Sinha

On Fri, Mar 11, 2011 at 10:12 AM, Stewart Smith
<email address hidden> wrote:
> On Thu, 10 Mar 2011 21:57:07 -0000, Akash Sinha <email address hidden> wrote:
>> --- drizzled/cursor.h 2011-03-07 12:31:41 +0000
>> +++ drizzled/cursor.h 2011-03-10 21:44:21 +0000
>> @@ -319,12 +319,12 @@
>>    virtual ha_rows estimate_rows_upper_bound()
>>    { return stats.records+EXTRA_RECORDS; }
>>
>> -  virtual const char *index_type(uint32_t)
>> +  virtual const char *index_type()
>>    { assert(0); return "";}
>
> It looks like index_type() is completely unused (apart from being implemented
> in every storage engine) - so instead of just removing the parameter
> (which shouldn't always be unused anyway) we should remove all the
> implementations of it too.
>
>> @@ -349,15 +349,15 @@
>>                                   const unsigned char * key,
>>                                   key_part_map keypart_map,
>>                                   enum ha_rkey_function find_flag);
>> -  virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))
>> -   { return  HA_ERR_WRONG_COMMAND; }
>> -  virtual int index_prev(unsigned char *)
>> -   { return  HA_ERR_WRONG_COMMAND; }
>> -  virtual int index_first(unsigned char *)
>> -   { return  HA_ERR_WRONG_COMMAND; }
>> -  virtual int index_last(unsigned char *)
>> -   { return  HA_ERR_WRONG_COMMAND; }
>> -  virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);
>> +  virtual int index_next() __attribute__ ((warn_unused_result))
>> +   { return  HA_ERR_WRONG_COMMAND; }
>> +  virtual int index_prev()
>> +   { return  HA_ERR_WRONG_COMMAND; }
>> +  virtual int index_first()
>> +   { return  HA_ERR_WRONG_COMMAND; }
>> +  virtual int index_last()
>> +   { return  HA_ERR_WRONG_COMMAND; }
>> +  virtual int index_next_same();
>
> This is incorrect, the buffer being passed in is important and at least
> *should* be used by classes implementing them.
>
>>  private:
>>    uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);
>> @@ -379,20 +379,20 @@
>>                                 bool eq_range, bool sorted);
>>    virtual int read_range_next();
>>    int compare_key(key_range *range);
>> -  virtual int rnd_next(unsigned char *)=0;
>> -  virtual int rnd_pos(unsigned char *, unsigned char *)=0;
>> +  virtual int rnd_next()=0;
>> +  virtual int rnd_pos()=0;
>
> the rnd_pos() method is used and does use the parameters (just not in
> the default implementation that does nothing), same with rnd_next() -
> that is used.
>
>>    virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
>> -  virtual int rnd_same(unsigned char *, uint32_t)
>> +  virtual int rnd_same()
>>      { return HA_ERR_WRONG...

Read more...

Revision history for this message
Akash Sinha (sinha) wrote :

I haven't touched any part of code rather than removing unused params
from the function definiton and testing it.This coding standard
violation the one with assignment thing might be present there in my
code trunk.

--Akash

On Fri, Mar 11, 2011 at 10:01 AM, Vijay Samuel <email address hidden> wrote:
> Review: Needs Fixing
> Hi Akash,
>  Good to see you submitting your first branch. Great job. There are coding standard violations in your branch. Please make it a point to adhere to all the coding guidelines inn the wiki page that I gave you.
>
> I ll just point out some of the obvious one that I could see,
> 1) assignment operations should be as follows,
>   a= b; one space after the = and nonee before.
>
> 2) use two space indentations for new blocks of code.
>
> 3)  braces must be written in new lines.
>
> Please make it a point to fix all the above mentioned and re submit your merge proposal.
>
> Cheers,
>  -Vijay
> --
> https://code.launchpad.net/~sinha/drizzle/trunk-bug-621856/+merge/52931
> You are the owner of lp:~sinha/drizzle/trunk-bug-621856.
>

Revision history for this message
Brian Aker (brianaker) wrote :

Thanks!

I'll just verify that the "=0" issue was in the original code. In general if you can fix stuff like this when you pass through the code that is great (and I can see if you are new to the code this might be an issue).

Stewart is right about some of these calls, you should see what warnings the compiler issues when you try to recompile.

Revision history for this message
Akash Sinha (sinha) wrote :

While working on this sometimes i get confused what to do.

Suppose there is function " int join_no_more_records(ReadRecord
*info); " in sql_select.h file
Now same function is implemented as " int
join_no_more_records(ReadRecord *) " in sql_select.cc file,Here there
is no params defined in this function in .cc file.

So what should be my action here ? Rremove that ReadRecord * from
sql_select.cc file as well as from sql_select.h file and check if that
function is implemented some other .cc file and rectify that also.

OR should i only check such kind of functions in .cc files as i found
one in sql_parese.cc file i.e function
TableList *Select_Lex::end_nested_join(Session *) as its entry is not
in sql_parse.h file.

Please reply in what manner i should proceed to fix this bug.

Thank you
Akash Sinha

On Fri, Mar 11, 2011 at 10:13 AM, Stewart Smith
<email address hidden> wrote:
> Review: Disapprove
>
> --
> https://code.launchpad.net/~sinha/drizzle/trunk-bug-621856/+merge/52931
> You are the owner of lp:~sinha/drizzle/trunk-bug-621856.
>

Unmerged revisions

2228. By Akash Sinha<email address hidden>

Removed functions with unused params

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches