Joseph Lukas wrote:
> Thanks for the info. I think I assumed Lex was more of a linked list based
> on MysQL's use of pointers for a lot of things and lack using the C++
> features that I am used to. I also wanted to make sure as push_back I have
> only seen in a vector for use. I am now reading up more on lists as I have
> only really used vectors in basic reading I see why they are used. I also
> had to make sure as I got confused as I knew I read somewhere to stay away
> from STL features in c++ and the likes for MySQL code in one of the
> tutorials.
One thing that has tripped me up a few times is remembering that the
custom List<> class template in MySQL *always* takes a pointer type as
it's template param. This is different from STL, so beware:
List<Table>
is actually:
std::list<Table *>
or even more like:
std::vector<Table *>
Just a word of caution :)
Cheers,
Jay
> Joe
>
> On 7/5/09 4:44 AM, "Sergei Golubchik" <serg@stripped> wrote:
>
>> Hi, Joseph!
>>
>>> As implementation I figured since the Lex is essentially a linked list
>>> I would traverse the Lex until the Select statements are reached and
>>> break the linked list. I would then make a List(Set Linked List) and
>>> call the set functions like it is doen normally. I would then find
>>> the Select functions and send to them. I figure during while
>>> traversing the Set statement I could copy the chain of variables that
>>> are to be Set this way before I send to the SET function I could
>>> retrieve the variables for GET to reset the values after I perform the
>>> SELECT. Does this sound logical or am I off in how the Lex is setup?
>> I'm confused. Where did you see that Lex is a linked list ?
>> SET stores variables in the Lex->var_list, that is in a list inside one
>> Lex, not in a list of Lex'es.
>>
>>> I will finally start on the traversing the Lex today after I take care
>>> of a few chores. If you could point me into how to start the at the
>>> first item and pointer type would be helpful and save time. Is there
>>> are pointer *start -> item or no in the YYTHD
>> Traversing the Lex->var_list ? If yes - see below.
>>
>>> Just a quick question is Lex->var_list a vector? As I see it uses
>>> .empty() and push_back . If that is the case I can go through it
>>> pretty quickly I think. Although given everything is pretty much
>>> linked lists used in mysql I would have thought it was a bunch of
>>> pointers in a linked list style. (even though a vector is likely a
>>> specialized linked list anyways being dynamic in size)
>> It's not an std::vector, if that's what you mean. MySQL doesn't use STL.
>> Lex->var_list is defined as
>>
>> List<set_var_base> var_list;
>>
>> and to iterate the list you use the following:
>>
>> List_iterator_fast<set_var_base> it(*Lex->var_list);
>> set_var_base *var;
>> while ((var=it++))
>> {
>> ... do something with 'var' ...
>> }
>>
>> see sql_set_variables() for an example.
>>
>> Regards / Mit vielen Grüßen,
>> Sergei
>
>
>
> --
> MySQL Internals Mailing List
> For list archives: http://lists.mysql.com/internals
> To unsubscribe: http://lists.mysql.com/internals?unsub=1
>