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

Proposed by Akash Sinha
Status: Superseded
Proposed branch: lp:~sinha/drizzle/trunk-bug-621856
Merge into: lp: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:~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.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
=== modified file 'drizzled/cursor.h'
--- drizzled/cursor.h 2011-03-07 12:31:41 +0000
+++ drizzled/cursor.h 2011-03-10 21:44:21 +0000
@@ -319,12 +319,12 @@
319 virtual ha_rows estimate_rows_upper_bound()319 virtual ha_rows estimate_rows_upper_bound()
320 { return stats.records+EXTRA_RECORDS; }320 { return stats.records+EXTRA_RECORDS; }
321321
322 virtual const char *index_type(uint32_t)322 virtual const char *index_type()
323 { assert(0); return "";}323 { assert(0); return "";}
324324
325325
326 uint32_t get_index(void) const { return active_index; }326 uint32_t get_index() const { return active_index; }
327 virtual int close(void)=0;327 virtual int close()=0;
328328
329 /**329 /**
330 @brief330 @brief
@@ -349,15 +349,15 @@
349 const unsigned char * key,349 const unsigned char * key,
350 key_part_map keypart_map,350 key_part_map keypart_map,
351 enum ha_rkey_function find_flag);351 enum ha_rkey_function find_flag);
352 virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))352 virtual int index_next() __attribute__ ((warn_unused_result))
353 { return HA_ERR_WRONG_COMMAND; }353 { return HA_ERR_WRONG_COMMAND; }
354 virtual int index_prev(unsigned char *)354 virtual int index_prev()
355 { return HA_ERR_WRONG_COMMAND; }355 { return HA_ERR_WRONG_COMMAND; }
356 virtual int index_first(unsigned char *)356 virtual int index_first()
357 { return HA_ERR_WRONG_COMMAND; }357 { return HA_ERR_WRONG_COMMAND; }
358 virtual int index_last(unsigned char *)358 virtual int index_last()
359 { return HA_ERR_WRONG_COMMAND; }359 { return HA_ERR_WRONG_COMMAND; }
360 virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);360 virtual int index_next_same();
361361
362private:362private:
363 uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);363 uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);
@@ -379,20 +379,20 @@
379 bool eq_range, bool sorted);379 bool eq_range, bool sorted);
380 virtual int read_range_next();380 virtual int read_range_next();
381 int compare_key(key_range *range);381 int compare_key(key_range *range);
382 virtual int rnd_next(unsigned char *)=0;382 virtual int rnd_next()=0;
383 virtual int rnd_pos(unsigned char *, unsigned char *)=0;383 virtual int rnd_pos()=0;
384 virtual int read_first_row(unsigned char *buf, uint32_t primary_key);384 virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
385 virtual int rnd_same(unsigned char *, uint32_t)385 virtual int rnd_same()
386 { return HA_ERR_WRONG_COMMAND; }386 { return HA_ERR_WRONG_COMMAND; }
387 virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)387 virtual ha_rows records_in_range()
388 { return (ha_rows) 10; }388 { return (ha_rows) 10; }
389 virtual void position(const unsigned char *record)=0;389 virtual void position(const unsigned char *record)=0;
390 virtual int info(uint32_t)=0; // see my_base.h for full description390 virtual int info()=0; // see my_base.h for full description
391 virtual uint32_t calculate_key_hash_value(Field **)391 virtual uint32_t calculate_key_hash_value()
392 { assert(0); return 0; }392 { assert(0); return 0; }
393 virtual int extra(enum ha_extra_function)393 virtual int extra(enum ha_extra_function)
394 { return 0; }394 { return 0; }
395 virtual int extra_opt(enum ha_extra_function operation, uint32_t)395 virtual int extra_opt(enum ha_extra_function operation)
396 { return extra(operation); }396 { return extra(operation); }
397397
398 /**398 /**
@@ -444,7 +444,7 @@
444 /* end of the list of admin commands */444 /* end of the list of admin commands */
445445
446 virtual int indexes_are_disabled(void) {return 0;}446 virtual int indexes_are_disabled(void) {return 0;}
447 virtual void append_create_info(String *)447 virtual void append_create_info()
448 {}448 {}
449 /**449 /**
450 If index == MAX_KEY then a check for table is made and if index <450 If index == MAX_KEY then a check for table is made and if index <
@@ -466,7 +466,7 @@
466 virtual int get_foreign_key_list(Session *, List<ForeignKeyInfo> *)466 virtual int get_foreign_key_list(Session *, List<ForeignKeyInfo> *)
467 { return 0; }467 { return 0; }
468 virtual uint32_t referenced_by_foreign_key() { return 0;}468 virtual uint32_t referenced_by_foreign_key() { return 0;}
469 virtual void free_foreign_key_create_info(char *) {}469 virtual void free_foreign_key_create_info() {}
470470
471 /**471 /**
472 Is not invoked for non-transactional temporary tables.472 Is not invoked for non-transactional temporary tables.
@@ -522,9 +522,9 @@
522 the corresponding 'ha_*' method above.522 the corresponding 'ha_*' method above.
523 */523 */
524524
525 virtual int open(const char *, int , uint32_t ) { assert(0); return -1; }525 virtual int open() { assert(0); return -1; }
526 virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);526 virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);
527 virtual int doStartIndexScan(uint32_t idx, bool)527 virtual int doStartIndexScan(uint32_t idx)
528 { active_index= idx; return 0; }528 { active_index= idx; return 0; }
529 virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }529 virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
530 /**530 /**
@@ -536,17 +536,17 @@
536 */536 */
537 virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;537 virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;
538 virtual int doEndTableScan() { return 0; }538 virtual int doEndTableScan() { return 0; }
539 virtual int doInsertRecord(unsigned char *)539 virtual int doInsertRecord()
540 {540 {
541 return HA_ERR_WRONG_COMMAND;541 return HA_ERR_WRONG_COMMAND;
542 }542 }
543543
544 virtual int doUpdateRecord(const unsigned char *, unsigned char *)544 virtual int doUpdateRecord()
545 {545 {
546 return HA_ERR_WRONG_COMMAND;546 return HA_ERR_WRONG_COMMAND;
547 }547 }
548548
549 virtual int doDeleteRecord(const unsigned char *)549 virtual int doDeleteRecord()
550 {550 {
551 return HA_ERR_WRONG_COMMAND;551 return HA_ERR_WRONG_COMMAND;
552 }552 }
@@ -579,7 +579,7 @@
579 @return non-0 in case of failure, 0 in case of success.579 @return non-0 in case of failure, 0 in case of success.
580 When lock_type is F_UNLCK, the return value is ignored.580 When lock_type is F_UNLCK, the return value is ignored.
581 */581 */
582 virtual int external_lock(Session *, int)582 virtual int external_lock()
583 {583 {
584 return 0;584 return 0;
585 }585 }
@@ -591,10 +591,9 @@
591 virtual void start_bulk_insert(ha_rows)591 virtual void start_bulk_insert(ha_rows)
592 {}592 {}
593 virtual int end_bulk_insert(void) { return 0; }593 virtual int end_bulk_insert(void) { return 0; }
594 virtual int index_read(unsigned char *, const unsigned char *,594 virtual int index_read( enum ha_rkey_function)
595 uint32_t, enum ha_rkey_function)
596 { return HA_ERR_WRONG_COMMAND; }595 { return HA_ERR_WRONG_COMMAND; }
597 virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)596 virtual int index_read_last()
598 { return (errno= HA_ERR_WRONG_COMMAND); }597 { return (errno= HA_ERR_WRONG_COMMAND); }
599 /**598 /**
600 This is called to delete all rows in a table599 This is called to delete all rows in a table
@@ -610,19 +609,19 @@
610 is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is609 is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
611 returned by storage engines that don't support this operation.610 returned by storage engines that don't support this operation.
612 */611 */
613 virtual int reset_auto_increment(uint64_t)612 virtual int reset_auto_increment()
614 { return HA_ERR_WRONG_COMMAND; }613 { return HA_ERR_WRONG_COMMAND; }
615614
616 virtual int analyze(Session *)615 virtual int analyze()
617 { return HA_ADMIN_NOT_IMPLEMENTED; }616 { return HA_ADMIN_NOT_IMPLEMENTED; }
618617
619 virtual int disable_indexes(uint32_t)618 virtual int disable_indexes()
620 { return HA_ERR_WRONG_COMMAND; }619 { return HA_ERR_WRONG_COMMAND; }
621620
622 virtual int enable_indexes(uint32_t)621 virtual int enable_indexes()
623 { return HA_ERR_WRONG_COMMAND; }622 { return HA_ERR_WRONG_COMMAND; }
624623
625 virtual int discard_or_import_tablespace(bool)624 virtual int discard_or_import_tablespace()
626 { return (errno=HA_ERR_WRONG_COMMAND); }625 { return (errno=HA_ERR_WRONG_COMMAND); }
627626
628 /* 627 /*
629628
=== modified file 'drizzled/sql_parse.cc'
--- drizzled/sql_parse.cc 2011-03-07 12:31:41 +0000
+++ drizzled/sql_parse.cc 2011-03-10 21:44:21 +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->getLex()->select_lex;1542 Select_Lex *select_lex= &session->getLex()->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

Subscribers

People subscribed via source and target branches