WL#4298: Metadata cache for all objects

Affects: Server-6.1   —   Status: Assigned

Extend the table definition cache to allow to store definitions of
 * views
 * stored procedures and functions
 * generally, any type of metadata

* the locking mechanism should allow coordination between multiple caches, while 
minimizing serialization of threads.


The current TDC API is:

struct TABLE_SHARE
{
  TABLE *used_tables;
  TABLE *unused_tables;
  void *frm_data;
};

/**
  Return a table share instance if it's in the cache
  The share shall be released to the TDC after it's
  not used with tdc_release_share().
*/

TABLE_SHARE *
tdc_find_share(const char *name);


/**
 Find or insert a new share. Looks up the share on disk and
 reads the .frm.
*/

TABLE_SHARE *
tdc_find_or_insert_share(const char *name);

/**
 Should follow each call to tdc_find_share() or
 tdc_find_or_insert_share()
*/

void
tdc_release_share(TABLE_SHARE *share);

/**
 Remove the share from the TDC.

 @precondition The share has no tables associated with it.
*/

void
tdc_remove_share(const char *name);

/**
 Move a table from unused_tables to used_tables list
*/

void
tdc_use_table(TABLE_SHARE *share, TABLE *table);

/**
 Move the table in the opposite direction.
*/

void
tdc_unuse_table(TABLE_SHARE *share, TABLE *table); 

/**
 Add a new table to used_tables list.
*/
void
tdc_add_table(TABLE_SHARE *share, TABLE *table);

/**
 Remove the table from unused_tables list.
*/

void
tdc_remove_table(TABLE_SHARE *share, TABLE *table);