Bug #45523 Objects of class base_ilist should not be copyable
Submitted: 16 Jun 2009 11:01 Modified: 7 Mar 2010 18:11
Reporter: Tor Didriksen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.4 OS:Any
Assigned to: Tor Didriksen CPU Architecture:Any

[16 Jun 2009 11:01] Tor Didriksen
Description:
class base_ilist has a WARNING comment about non-copyability, but the compiler-generated copy constructor, and assignment operator, are still public.

How to repeat:
NA

Suggested fix:
Declare, but don't define, private copy constructor and assignment operator.
Add member function for explicit copying of list members instead.
Change the handful of places which copied base_ilist objects.

Consider adding something like this to prevent copying:
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
  TypeName(const TypeName&);               \
  void operator=(const TypeName&)

but where should that declaration go?
[19 Jun 2009 0:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/76628

2802 Tor Didriksen	2009-06-18
      Bug#45523 "Objects of class base_ilist should not be copyable".
      
      Suppress the compiler-generated public copy constructor
      and assignment operator of class base_ilist; instead, implement
      move_elements() function which transfers ownership of elements
      from one list to another.
      
      Tested with:
      BUILD/compile-pentium-debug-max
      mysql-test/mtr --mem --force
     @ sql/sp_head.cc
        Use base_ilist::move_elements() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_cursor.cc
        Use base_ilist::move_elements() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_list.h
        make member variables first and last private
        fix typo in 'friend class ...iterator'
        disable the compiler generated copy CTOR and assignment operator
        implement new function base_ilist::move_elements() instead
     @ sql/sql_prepare.cc
        Use base_ilist::move_elements() rather than assignment operator
        to move elements from thd->change_list to a new owner
[23 Jun 2009 11:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/76906

2805 Tor Didriksen	2009-06-23
      Bug#45523 "Objects of class base_ilist should not be copyable".
      
      Suppress the compiler-generated public copy constructor
      and assignment operator of class base_ilist; instead, implement
      move_elements_to() function which transfers ownership of elements
      from one list to another.
      
      Tested with:
      BUILD/compile-pentium-debug-max
      mysql-test/mtr --mem --force
     @ sql/sp_head.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_cursor.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_list.h
        make member variables first and last private
        fix typo in 'friend class ...iterator'
        disable the compiler generated copy CTOR and assignment operator
        implement new function base_ilist::move_elements_to() instead
     @ sql/sql_prepare.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
[23 Jun 2009 13:49] Timour Katchaounov
The patch is OK for me, though I have no idea where to push it.
I have no good suggestion also about the proposed macro.
[24 Jun 2009 7:11] Tor Didriksen
Tested with
BUILD/compile-pentium-debug-max
mysql-test/mtr --mem --force
mysql-test/mtr --mem --force --sp-protocol
[24 Jul 2009 14:48] Konstantin Osipov
Tor, please get in touch with me about pushing this.
Patches shouldn't get stuck in "Patch approved" state.
[17 Aug 2009 12:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80884

2857 Tor Didriksen	2009-08-17
      Bug#45523 "Objects of class base_ilist should not be copyable".
      
      Suppress the compiler-generated public copy constructor
      and assignment operator of class base_ilist; instead, implement
      move_elements_to() function which transfers ownership of elements
      from one list to another.
      
      Tested with:
      BUILD/compile-pentium-debug-max
      mysql-test/mtr --mem --force
     @ sql/sp_head.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_cursor.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
     @ sql/sql_list.h
        make member variables first and last private
        fix typo in 'friend class ...iterator'
        disable the compiler generated copy CTOR and assignment operator
        implement new function base_ilist::move_elements_to() instead
     @ sql/sql_prepare.cc
        Use base_ilist::move_elements_to() rather than assignment operator
        to move elements from thd->change_list to a new owner
[19 Aug 2009 10:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/81057

2867 Tor Didriksen	2009-08-19
            Bug#45523 "Objects of class base_ilist should not be copyable".
       
            Suppress the compiler-generated public copy constructor
            and assignment operator of class base_ilist; instead, implement
            move_elements_to() function which transfers ownership of elements
            from one list to another.
     @ sql/sp_head.cc
        
                Use base_ilist::move_elements_to() rather than assignment operator
                to move elements from thd->change_list to a new owner
     @ sql/sql_cursor.cc
        
                Use base_ilist::move_elements_to() rather than assignment operator
                to move elements from thd->change_list to a new owner
     @ sql/sql_list.h
                make member variables first and last private
                fix typo in 'friend class ...iterator'
                disable the compiler generated copy CTOR and assignment operator
                implement new function base_ilist::move_elements_to() instead
     @ sql/sql_prepare.cc
        
                Use base_ilist::move_elements_to() rather than assignment operator
                to move elements from thd->change_list to a new owner
[20 Aug 2009 12:45] Tor Didriksen
pushed to mysql-next-bugfixing at
2009-08-19 12:48:15
[21 Aug 2009 6:44] Tor Didriksen
Pushed into mysql-next-bugfixing, currently tagged 5.4.4
[24 Aug 2009 13:54] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090824135126-2rngffvth14a8bpj) (version source revid:tor.didriksen@sun.com-20090819103926-a4c0siwzs74y4sle) (merge vers: 5.4.4-alpha) (pib:11)
[26 Aug 2009 2:33] Paul DuBois
No changelog entry needed.
[12 Jan 2010 11:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/96597

3049 Tor Didriksen	2010-01-12
      Backport of
      Bug#45523 "Objects of class base_ilist should not be copyable".
                     
      Suppress the compiler-generated public copy constructor
      and assignment operator of class base_ilist; instead, implement
      move_elements_to() function which transfers ownership of elements
      from one list to another.
[16 Feb 2010 16:51] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:tor.didriksen@sun.com-20100112123609-xtohejeg57r0nu5m) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 17:00] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:tor.didriksen@sun.com-20100112113255-2hd07faifl255fei) (pib:16)
[17 Feb 2010 0:47] Paul DuBois
Setting report to Need Merge pending push of Celosia into release tree.
[6 Mar 2010 11:09] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20100216221947-luyhph0txl2c5tc8) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 12:41] Paul DuBois
No changelog entry needed.