List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:November 29 2010 11:56am
Subject:Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393
View as plain text  
On 11/29/2010 11:35 AM, Øystein Grøvlen wrote:
> On 11/29/10 11:03 AM, Jorgen Loland wrote:
> ...
>
>  > > === added file 'sql/bounded_queue.h'
>  > > --- sql/bounded_queue.h 1970-01-01 00:00:00 +0000
>  > > +++ sql/bounded_queue.h 2010-11-26 14:13:02 +0000
>  > > @@ -0,0 +1,199 @@
>  > > (...)
>  > > + Key_type **pop()
>  > > + {
>  > > + // Don't return the extra element to the client code.
>  > > + if (queue_is_full((&m_queue)))
>  > > + queue_remove(&m_queue, 0);
>  > > + return reinterpret_cast<Key_type**>(queue_remove(&m_queue,
> 0));
>  > > + }
>  >
>  > JL: I suggest a DBUG_ASSERT(m_queue.elements>0); and a unit test that
>  > hits it.
>  >
>
> I do not think we should require that the caller needs to keep track
> of how many elements there are in the queue. I think it is better if
> NULL is returned when the queue is empty.
>

Even better. Before writing the comment I had modified one of the unit tests to 
pop more elements than had been pushed and got a segfault (not surprisingly). 
Hence, I think we need to be explicit on how it works. We either
a) make it explicit that pop() can only be called if the BQ contains elements, or
b) return NULL if empty as suggested by Øystein.

-- 
Jørgen Løland | Senior Software Engineer | +47 73842138
Oracle MySQL
Trondheim, Norway
Thread
bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Tor Didriksen24 Nov
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Jorgen Loland29 Nov
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Øystein Grøvlen29 Nov
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Jorgen Loland29 Nov
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Tor Didriksen1 Dec
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Tor Didriksen30 Nov
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3247) WL#1393Jorgen Loland3 Dec