[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-developer
Subject:    Thread and other safety
From:       Michael Widenius <monty () monty ! pp ! sci ! fi>
Date:       1999-10-14 20:08:19
[Download RAW message or body]


Hi!

>>>>> "sasha" == sasha  <sasha@freeservers.com> writes:

sasha> Monty:
sasha> I am running into trouble somewhere while trying to implement
sasha> per-connection user variables, and before I spend to much running around
sasha> in circles, I would like to learn some safety rules.

sasha>  - Can you think of a reason why it would not be safe to call   new 
sasha> hash_info () inside THD::THD() ?  Is there anyhting special that would
sasha> need to be done to do it safely

As long as 'hash_info' is using ':public Sql_alloc' this should be
safe.

sasha>  - Is it safe to call malloc() inside a constructor of a class derived
sasha> from Item_func and then instantiate the class in sql_yacc.yy during
sasha> query parsing?

This should be safe.  Note however that when a query ends, all Items
will automaticly be released by 'sql_parse.cc:free_items()'

sasha>  - Are there any other non-trivial safety rules I need to be aware of
sasha> when implementing a function.
  
Data in items (and other structures) that should be automaticly
released when a query ends, should inherit from Sql_alloc or use
sql_alloc() to allocate memory.  Note that this memory can't be
resized and the 'free' functions will not be called for anything else
than items.  (Items are kept in a linked list to make it easy to
optimize away items in the optimize without having to think about
freeing them, which may sometimes be a bit hard as they can include
linked, sometimes circular dependencies)

Regards,
Monty

PS: I did a CC to the developer list as this may be interesting to
    others...

---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail developer-thread326@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail developer-unsubscribe@lists.mysql.com instead.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic