~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/ha_heap.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    return ha_heap_exts;
57
57
  }
58
58
 
59
 
  int createTableImplementation(Session *session, const char *table_name,
60
 
                                Table *table_arg, HA_CREATE_INFO *create_info,
61
 
                                drizzled::message::Table*);
 
59
  int doCreateTable(Session *session, 
 
60
                    const char *table_name,
 
61
                    Table& table_arg, 
 
62
                    HA_CREATE_INFO& create_info,
 
63
                    drizzled::message::Table&);
62
64
 
63
65
  /* For whatever reason, internal tables can be created by Cursor::open()
64
66
     for HEAP.
66
68
     at night with this odd hackish workaround.
67
69
   */
68
70
  int heap_create_table(Session *session, const char *table_name,
69
 
                        Table *table_arg, HA_CREATE_INFO *create_info,
 
71
                        Table *table_arg, HA_CREATE_INFO& create_info,
70
72
                        bool internal_table,
71
73
                        HP_SHARE **internal_share);
72
74
 
73
 
  int renameTableImplementation(Session*, const char * from, const char * to);
74
 
 
75
 
  int deleteTableImplementation(Session *, const string table_path);
 
75
  int doRenameTable(Session*, const char * from, const char * to);
 
76
 
 
77
  int doDropTable(Session&, const string table_path);
 
78
 
 
79
  int doGetTableDefinition(Session& session,
 
80
                           const char* path,
 
81
                           const char *db,
 
82
                           const char *table_name,
 
83
                           const bool is_tmp,
 
84
                           drizzled::message::Table *table_proto);
 
85
 
 
86
  /* Temp only engine, so do not return values. */
 
87
  void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
 
88
 
76
89
};
77
90
 
 
91
int HeapEngine::doGetTableDefinition(Session&,
 
92
                                     const char* path,
 
93
                                     const char *,
 
94
                                     const char *,
 
95
                                     const bool,
 
96
                                     drizzled::message::Table *table_proto)
 
97
{
 
98
  int error= 1;
 
99
  ProtoCache::iterator iter;
 
100
 
 
101
  pthread_mutex_lock(&proto_cache_mutex);
 
102
  iter= proto_cache.find(path);
 
103
 
 
104
  if (iter!= proto_cache.end())
 
105
  {
 
106
    if (table_proto)
 
107
      table_proto->CopyFrom(((*iter).second));
 
108
    error= EEXIST;
 
109
  }
 
110
  pthread_mutex_unlock(&proto_cache_mutex);
 
111
 
 
112
  return error;
 
113
}
78
114
/*
79
115
  We have to ignore ENOENT entries as the HEAP table is created on open and
80
116
  not when doing a CREATE on the table.
81
117
*/
82
 
int HeapEngine::deleteTableImplementation(Session*, const string table_path)
 
118
int HeapEngine::doDropTable(Session&, const string table_path)
83
119
{
 
120
  ProtoCache::iterator iter;
 
121
 
 
122
  pthread_mutex_lock(&proto_cache_mutex);
 
123
  iter= proto_cache.find(table_path.c_str());
 
124
 
 
125
  if (iter!= proto_cache.end())
 
126
    proto_cache.erase(iter);
 
127
  pthread_mutex_unlock(&proto_cache_mutex);
 
128
 
84
129
  return heap_delete_table(table_path.c_str());
85
130
}
86
131
 
141
186
    file= 0;
142
187
    HP_SHARE *internal_share= NULL;
143
188
    if (!heap_storage_engine->heap_create_table(ha_session(), name, table,
144
 
                                                &create_info,
 
189
                                                create_info,
145
190
                                                internal_table,&internal_share))
146
191
    {
147
192
        file= internal_table ?
610
655
}
611
656
 
612
657
 
613
 
int HeapEngine::renameTableImplementation(Session*,
614
 
                                          const char *from, const char *to)
 
658
int HeapEngine::doRenameTable(Session*,
 
659
                              const char *from, const char *to)
615
660
{
616
661
  return heap_rename(from,to);
617
662
}
639
684
  return key->rec_per_key[key->key_parts-1];
640
685
}
641
686
 
642
 
int HeapEngine::createTableImplementation(Session *session,
643
 
                                          const char *table_name,
644
 
                                          Table *table_arg,
645
 
                                          HA_CREATE_INFO *create_info,
646
 
                                          drizzled::message::Table*)
 
687
int HeapEngine::doCreateTable(Session *session,
 
688
                              const char *table_name,
 
689
                              Table& table_arg,
 
690
                              HA_CREATE_INFO& create_info,
 
691
                              drizzled::message::Table& create_proto)
647
692
{
 
693
  int error;
648
694
  HP_SHARE *internal_share;
649
 
  return heap_create_table(session, table_name, table_arg, create_info,
 
695
 
 
696
  error= heap_create_table(session, table_name, &table_arg, create_info,
650
697
                           false, &internal_share);
 
698
 
 
699
  if (error == 0)
 
700
  {
 
701
    pthread_mutex_lock(&proto_cache_mutex);
 
702
    proto_cache.insert(make_pair(table_name, create_proto));
 
703
    pthread_mutex_unlock(&proto_cache_mutex);
 
704
  }
 
705
 
 
706
  return error;
651
707
}
652
708
 
653
709
 
654
710
int HeapEngine::heap_create_table(Session *session, const char *table_name,
655
 
                             Table *table_arg, HA_CREATE_INFO *create_info,
 
711
                             Table *table_arg, HA_CREATE_INFO& create_info,
656
712
                             bool internal_table, HP_SHARE **internal_share)
657
713
{
658
714
  uint32_t key, parts, mem_per_row_keys= 0, keys= table_arg->s->keys;
822
878
  HP_CREATE_INFO hp_create_info;
823
879
  hp_create_info.auto_key= auto_key;
824
880
  hp_create_info.auto_key_type= auto_key_type;
825
 
  hp_create_info.auto_increment= (create_info->auto_increment_value ?
826
 
                                  create_info->auto_increment_value - 1 : 0);
 
881
  hp_create_info.auto_increment= (create_info.auto_increment_value ?
 
882
                                  create_info.auto_increment_value - 1 : 0);
827
883
  hp_create_info.max_table_size=session->variables.max_heap_table_size;
828
884
  hp_create_info.with_auto_increment= found_real_auto_increment;
829
885
  hp_create_info.internal_table= internal_table;
864
920
}
865
921
 
866
922
 
867
 
drizzle_declare_plugin(heap)
 
923
drizzle_declare_plugin
868
924
{
869
925
  "MEMORY",
870
926
  "1.0",