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

Proposed by Monty Taylor
Status: Work in progress
Proposed branch: lp:~sinha/drizzle/trunk-bug-621856
Merge into: lp:~drizzle-trunk/drizzle/development
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:~sinha/drizzle/trunk-bug-621856
Reviewer Review Type Date Requested Status
Stewart Smith Pending
David Shrewsbury Pending
Vijay Samuel Pending
Review via email: mp+53535@code.launchpad.net

This proposal supersedes a proposal from 2011-03-10.

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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) : Posted in a previous version of this proposal
review: Disapprove
Revision history for this message
Akash Sinha (sinha) wrote : Posted in a previous version of this proposal
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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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
=== modified file 'drizzled/cursor.h'
--- drizzled/cursor.h 2011-03-14 05:40:28 +0000
+++ drizzled/cursor.h 2011-03-15 22:31:52 +0000
@@ -318,12 +318,12 @@
318 virtual ha_rows estimate_rows_upper_bound()318 virtual ha_rows estimate_rows_upper_bound()
319 { return stats.records+EXTRA_RECORDS; }319 { return stats.records+EXTRA_RECORDS; }
320320
321 virtual const char *index_type(uint32_t)321 virtual const char *index_type()
322 { assert(0); return "";}322 { assert(0); return "";}
323323
324324
325 uint32_t get_index(void) const { return active_index; }325 uint32_t get_index() const { return active_index; }
326 virtual int close(void)=0;326 virtual int close()=0;
327327
328 /**328 /**
329 @brief329 @brief
@@ -348,15 +348,15 @@
348 const unsigned char * key,348 const unsigned char * key,
349 key_part_map keypart_map,349 key_part_map keypart_map,
350 enum ha_rkey_function find_flag);350 enum ha_rkey_function find_flag);
351 virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))351 virtual int index_next() __attribute__ ((warn_unused_result))
352 { return HA_ERR_WRONG_COMMAND; }352 { return HA_ERR_WRONG_COMMAND; }
353 virtual int index_prev(unsigned char *)353 virtual int index_prev()
354 { return HA_ERR_WRONG_COMMAND; }354 { return HA_ERR_WRONG_COMMAND; }
355 virtual int index_first(unsigned char *)355 virtual int index_first()
356 { return HA_ERR_WRONG_COMMAND; }356 { return HA_ERR_WRONG_COMMAND; }
357 virtual int index_last(unsigned char *)357 virtual int index_last()
358 { return HA_ERR_WRONG_COMMAND; }358 { return HA_ERR_WRONG_COMMAND; }
359 virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);359 virtual int index_next_same();
360360
361private:361private:
362 uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);362 uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);
@@ -378,20 +378,20 @@
378 bool eq_range, bool sorted);378 bool eq_range, bool sorted);
379 virtual int read_range_next();379 virtual int read_range_next();
380 int compare_key(key_range *range);380 int compare_key(key_range *range);
381 virtual int rnd_next(unsigned char *)=0;381 virtual int rnd_next()=0;
382 virtual int rnd_pos(unsigned char *, unsigned char *)=0;382 virtual int rnd_pos()=0;
383 virtual int read_first_row(unsigned char *buf, uint32_t primary_key);383 virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
384 virtual int rnd_same(unsigned char *, uint32_t)384 virtual int rnd_same()
385 { return HA_ERR_WRONG_COMMAND; }385 { return HA_ERR_WRONG_COMMAND; }
386 virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)386 virtual ha_rows records_in_range()
387 { return (ha_rows) 10; }387 { return (ha_rows) 10; }
388 virtual void position(const unsigned char *record)=0;388 virtual void position(const unsigned char *record)=0;
389 virtual int info(uint32_t)=0; // see my_base.h for full description389 virtual int info()=0; // see my_base.h for full description
390 virtual uint32_t calculate_key_hash_value(Field **)390 virtual uint32_t calculate_key_hash_value()
391 { assert(0); return 0; }391 { assert(0); return 0; }
392 virtual int extra(enum ha_extra_function)392 virtual int extra(enum ha_extra_function)
393 { return 0; }393 { return 0; }
394 virtual int extra_opt(enum ha_extra_function operation, uint32_t)394 virtual int extra_opt(enum ha_extra_function operation)
395 { return extra(operation); }395 { return extra(operation); }
396396
397 /**397 /**
@@ -443,7 +443,7 @@
443 /* end of the list of admin commands */443 /* end of the list of admin commands */
444444
445 virtual int indexes_are_disabled(void) {return 0;}445 virtual int indexes_are_disabled(void) {return 0;}
446 virtual void append_create_info(String *)446 virtual void append_create_info()
447 {}447 {}
448 /**448 /**
449 If index == MAX_KEY then a check for table is made and if index <449 If index == MAX_KEY then a check for table is made and if index <
@@ -465,7 +465,7 @@
465 virtual int get_foreign_key_list(Session *, List<ForeignKeyInfo> *)465 virtual int get_foreign_key_list(Session *, List<ForeignKeyInfo> *)
466 { return 0; }466 { return 0; }
467 virtual uint32_t referenced_by_foreign_key() { return 0;}467 virtual uint32_t referenced_by_foreign_key() { return 0;}
468 virtual void free_foreign_key_create_info(char *) {}468 virtual void free_foreign_key_create_info() {}
469469
470 /**470 /**
471 Is not invoked for non-transactional temporary tables.471 Is not invoked for non-transactional temporary tables.
@@ -521,9 +521,9 @@
521 the corresponding 'ha_*' method above.521 the corresponding 'ha_*' method above.
522 */522 */
523523
524 virtual int open(const char *, int , uint32_t ) { assert(0); return -1; }524 virtual int open() { assert(0); return -1; }
525 virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);525 virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);
526 virtual int doStartIndexScan(uint32_t idx, bool)526 virtual int doStartIndexScan(uint32_t idx)
527 { active_index= idx; return 0; }527 { active_index= idx; return 0; }
528 virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }528 virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
529 /**529 /**
@@ -535,17 +535,17 @@
535 */535 */
536 virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;536 virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;
537 virtual int doEndTableScan() { return 0; }537 virtual int doEndTableScan() { return 0; }
538 virtual int doInsertRecord(unsigned char *)538 virtual int doInsertRecord()
539 {539 {
540 return HA_ERR_WRONG_COMMAND;540 return HA_ERR_WRONG_COMMAND;
541 }541 }
542542
543 virtual int doUpdateRecord(const unsigned char *, unsigned char *)543 virtual int doUpdateRecord()
544 {544 {
545 return HA_ERR_WRONG_COMMAND;545 return HA_ERR_WRONG_COMMAND;
546 }546 }
547547
548 virtual int doDeleteRecord(const unsigned char *)548 virtual int doDeleteRecord()
549 {549 {
550 return HA_ERR_WRONG_COMMAND;550 return HA_ERR_WRONG_COMMAND;
551 }551 }
@@ -578,7 +578,7 @@
578 @return non-0 in case of failure, 0 in case of success.578 @return non-0 in case of failure, 0 in case of success.
579 When lock_type is F_UNLCK, the return value is ignored.579 When lock_type is F_UNLCK, the return value is ignored.
580 */580 */
581 virtual int external_lock(Session *, int)581 virtual int external_lock()
582 {582 {
583 return 0;583 return 0;
584 }584 }
@@ -590,10 +590,9 @@
590 virtual void start_bulk_insert(ha_rows)590 virtual void start_bulk_insert(ha_rows)
591 {}591 {}
592 virtual int end_bulk_insert(void) { return 0; }592 virtual int end_bulk_insert(void) { return 0; }
593 virtual int index_read(unsigned char *, const unsigned char *,593 virtual int index_read( enum ha_rkey_function)
594 uint32_t, enum ha_rkey_function)
595 { return HA_ERR_WRONG_COMMAND; }594 { return HA_ERR_WRONG_COMMAND; }
596 virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)595 virtual int index_read_last()
597 { return (errno= HA_ERR_WRONG_COMMAND); }596 { return (errno= HA_ERR_WRONG_COMMAND); }
598 /**597 /**
599 This is called to delete all rows in a table598 This is called to delete all rows in a table
@@ -609,19 +608,19 @@
609 is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is608 is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
610 returned by storage engines that don't support this operation.609 returned by storage engines that don't support this operation.
611 */610 */
612 virtual int reset_auto_increment(uint64_t)611 virtual int reset_auto_increment()
613 { return HA_ERR_WRONG_COMMAND; }612 { return HA_ERR_WRONG_COMMAND; }
614613
615 virtual int analyze(Session *)614 virtual int analyze()
616 { return HA_ADMIN_NOT_IMPLEMENTED; }615 { return HA_ADMIN_NOT_IMPLEMENTED; }
617616
618 virtual int disable_indexes(uint32_t)617 virtual int disable_indexes()
619 { return HA_ERR_WRONG_COMMAND; }618 { return HA_ERR_WRONG_COMMAND; }
620619
621 virtual int enable_indexes(uint32_t)620 virtual int enable_indexes()
622 { return HA_ERR_WRONG_COMMAND; }621 { return HA_ERR_WRONG_COMMAND; }
623622
624 virtual int discard_or_import_tablespace(bool)623 virtual int discard_or_import_tablespace()
625 { return (errno=HA_ERR_WRONG_COMMAND); }624 { return (errno=HA_ERR_WRONG_COMMAND); }
626625
627 /* 626 /*
628627
=== modified file 'drizzled/sql_parse.cc'
--- drizzled/sql_parse.cc 2011-03-10 13:40:36 +0000
+++ drizzled/sql_parse.cc 2011-03-15 22:31:52 +0000
@@ -1127,7 +1127,7 @@
1127 - 0, otherwise1127 - 0, otherwise
1128*/1128*/
11291129
1130TableList *Select_Lex::end_nested_join(Session *)1130TableList *Select_Lex::end_nested_join()
1131{1131{
1132 TableList *ptr;1132 TableList *ptr;
1133 NestedJoin *nested_join;1133 NestedJoin *nested_join;
@@ -1536,7 +1536,7 @@
1536 true Error1536 true Error
1537*/1537*/
15381538
1539bool update_precheck(Session *session, TableList *)1539bool update_precheck(Session *session)
1540{1540{
1541 const char *msg= 0;1541 const char *msg= 0;
1542 Select_Lex *select_lex= &session->lex().select_lex;1542 Select_Lex *select_lex= &session->lex().select_lex;
@@ -1575,7 +1575,7 @@
1575 true error1575 true error
1576*/1576*/
15771577
1578bool insert_precheck(Session *session, TableList *)1578bool insert_precheck(Session *session)
1579{1579{
1580 /*1580 /*
1581 Check that we have modify privileges for the first table and1581 Check that we have modify privileges for the first table and