~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/table_cache_dictionary/table_definition_cache.cc

  • Committer: Brian Aker
  • Date: 2010-11-19 03:03:40 UTC
  • mto: (1945.2.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1944.
  • Revision ID: brian@tangent.org-20101119030340-vw9l27v75r317o55
Added generator for table_definition cache. Now no one can touch the guts :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "config.h"
22
22
 
23
23
#include "plugin/table_cache_dictionary/dictionary.h"
24
 
#include "drizzled/pthread_globals.h"
25
24
 
26
25
using namespace drizzled;
27
26
using namespace std;
37
36
}
38
37
 
39
38
table_cache_dictionary::TableDefinitionCache::Generator::Generator(drizzled::Field **arg) :
40
 
  drizzled::plugin::TableFunction::Generator(arg),
41
 
  is_primed(false)
 
39
  drizzled::plugin::TableFunction::Generator(arg)
42
40
{
43
 
  LOCK_open.lock(); /* Optionally lock for remove tables from open_cahe if not in use */
44
41
}
45
42
 
46
43
table_cache_dictionary::TableDefinitionCache::Generator::~Generator()
47
44
{
48
 
  LOCK_open.unlock(); /* Optionally lock for remove tables from open_cahe if not in use */
49
 
}
50
 
 
51
 
bool table_cache_dictionary::TableDefinitionCache::Generator::nextCore()
52
 
{
53
 
  if (is_primed)
54
 
  {
55
 
    table_share_iterator++;
56
 
  }
57
 
  else
58
 
  {
59
 
    is_primed= true;
60
 
    table_share_iterator= definition::Cache::singleton().getCache().begin();
61
 
  }
62
 
 
63
 
  if (table_share_iterator == definition::Cache::singleton().getCache().end())
64
 
    return false;
65
 
 
66
 
  share= (*table_share_iterator).second;
67
 
 
68
 
  return true;
69
 
}
70
 
 
71
 
bool table_cache_dictionary::TableDefinitionCache::Generator::next()
72
 
{
73
 
  while (not nextCore())
74
 
  {
75
 
    if (table_share_iterator != definition::Cache::singleton().getCache().end())
76
 
      continue;
77
 
 
78
 
    return false;
79
 
  }
80
 
 
81
 
  return true;
82
45
}
83
46
 
84
47
bool table_cache_dictionary::TableDefinitionCache::Generator::populate()
85
48
{
86
 
  if (not next())
87
 
    return false;
88
 
  
89
 
  fill();
90
 
 
91
 
  return true;
92
 
}
93
 
 
94
 
void table_cache_dictionary::TableDefinitionCache::Generator::fill()
95
 
{
96
 
  /**
97
 
    For test cases use:
98
 
    --replace_column 3 # 4 # 5 #
99
 
  */
100
 
 
101
 
  /* TABLE_SCHEMA 1 */
102
 
  string arg;
103
 
  push(share->getSchemaName(arg));
104
 
 
105
 
  /* TABLE_NAME  2 */
106
 
  push(share->getTableName(arg));
107
 
 
108
 
  /* VERSION 3 */
109
 
  push(static_cast<int64_t>(share->getVersion()));
110
 
 
111
 
  /* TABLE_COUNT 4 */
112
 
  push(static_cast<uint64_t>(share->getTableCount()));
113
 
 
114
 
  /* IS_NAME_LOCKED */
115
 
  push(false);
 
49
  drizzled::TableShare::shared_ptr share;
 
50
 
 
51
  while ((share= table_definition_cache_generator))
 
52
  {
 
53
    /**
 
54
      For test cases use:
 
55
      --replace_column 3 # 4 # 5 #
 
56
    */
 
57
 
 
58
    /* TABLE_SCHEMA 1 */
 
59
    string arg;
 
60
    push(share->getSchemaName(arg));
 
61
 
 
62
    /* TABLE_NAME  2 */
 
63
    push(share->getTableName(arg));
 
64
 
 
65
    /* VERSION 3 */
 
66
    push(static_cast<int64_t>(share->getVersion()));
 
67
 
 
68
    /* TABLE_COUNT 4 */
 
69
    push(static_cast<uint64_t>(share->getTableCount()));
 
70
 
 
71
    /* IS_NAME_LOCKED */
 
72
    push(false);
 
73
 
 
74
    return true;
 
75
  }
 
76
 
 
77
  return false;
116
78
}