~stewart/drizzle/embedded-innodb-create-table-with-index

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Stewart Smith
  • Date: 2010-03-11 01:15:57 UTC
  • mfrom: (1319.1.29)
  • Revision ID: stewart@flamingspork.com-20100311011557-49r2ye69bqh4abti
Merged embedded-innodb-rnd-read into embedded-innodb-create-table-with-index.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#include "drizzled/global_charset_info.h"
52
52
#include "drizzled/pthread_globals.h"
53
53
#include "drizzled/internal/iocache.h"
 
54
#include "drizzled/plugin/authorization.h"
54
55
 
55
56
using namespace std;
56
57
 
85
86
  return (unsigned char*) entry->s->table_cache_key.str;
86
87
}
87
88
 
 
89
HASH *get_open_cache()
 
90
{
 
91
  return &open_cache;
 
92
}
 
93
 
88
94
 
89
95
bool table_cache_init(void)
90
96
{
99
105
  refresh_version++;                            // Force close of open tables
100
106
 
101
107
  while (unused_tables)
102
 
    hash_delete(&open_cache,(unsigned char*) unused_tables);
 
108
    hash_delete(&open_cache, (unsigned char*) unused_tables);
103
109
 
104
 
  if (!open_cache.records)                      // Safety first
 
110
  if (not open_cache.records)                   // Safety first
105
111
    hash_free(&open_cache);
106
112
}
107
113
 
188
194
{
189
195
  Table *table= static_cast<Table *>(entry);
190
196
  table->intern_close_table();
191
 
  if (!table->in_use)
 
197
  if (not table->in_use)
192
198
  {
193
199
    table->next->prev=table->prev;              /* remove from used chain */
194
200
    table->prev->next=table->next;
485
491
{
486
492
  for (; table; table= table->*link )
487
493
  {
488
 
    if ((table->table == 0 || table->table->s->tmp_table == NO_TMP_TABLE) &&
 
494
    if ((table->table == 0 || table->table->s->tmp_table == STANDARD_TABLE) &&
489
495
        strcmp(table->db, db_name) == 0 &&
490
496
        strcmp(table->table_name, table_name) == 0)
491
497
      break;
549
555
  if (table->table)
550
556
  {
551
557
    /* temporary table is always unique */
552
 
    if (table->table && table->table->s->tmp_table != NO_TMP_TABLE)
 
558
    if (table->table && table->table->s->tmp_table != STANDARD_TABLE)
553
559
      return 0;
554
560
    table= table->find_underlying_table(table->table);
555
561
    /*
787
793
      that something has happened.
788
794
    */
789
795
    unlink_open_table(table);
790
 
    TableIdentifier identifier(db_name, table_name, NO_TMP_TABLE);
 
796
    TableIdentifier identifier(db_name, table_name, STANDARD_TABLE);
791
797
    quick_rm_table(*this, identifier);
792
798
    pthread_mutex_unlock(&LOCK_open);
793
799
  }
1283
1289
 
1284
1290
    if (table_list->create)
1285
1291
    {
1286
 
      TableIdentifier  lock_table_identifier(table_list->db, table_list->table_name, NO_TMP_TABLE);
 
1292
      TableIdentifier  lock_table_identifier(table_list->db, table_list->table_name, STANDARD_TABLE);
1287
1293
 
1288
 
      if (plugin::StorageEngine::getTableDefinition(*this, lock_table_identifier) != EEXIST)
 
1294
      if (not plugin::StorageEngine::doesTableExist(*this, lock_table_identifier))
1289
1295
      {
1290
1296
        /*
1291
1297
          Table to be created, so we need to create placeholder in table-cache.
1337
1343
  table->reginfo.lock_type= TL_READ; /* Assume read */
1338
1344
 
1339
1345
reset:
1340
 
  assert(table->s->ref_count > 0 || table->s->tmp_table != NO_TMP_TABLE);
 
1346
  assert(table->s->ref_count > 0 || table->s->tmp_table != STANDARD_TABLE);
1341
1347
 
1342
1348
  if (lex->need_correct_ident())
1343
1349
    table->alias_name_used= my_strcasecmp(table_alias_charset,
2030
2036
    (*counter)++;
2031
2037
 
2032
2038
    /*
 
2039
     * Is the user authorized to see this table? Do this before we check
 
2040
     * to see if it exists so that an unauthorized user cannot phish for
 
2041
     * table/schema information via error messages
 
2042
     */
 
2043
    if (not plugin::Authorization::isAuthorized(getSecurityContext(),
 
2044
                                                string(tables->db),
 
2045
                                                string(tables->table_name)))
 
2046
    {
 
2047
      result= -1;                               // Fatal error
 
2048
      break;
 
2049
    }
 
2050
 
 
2051
 
 
2052
    /*
2033
2053
      Not a placeholder: must be a base table or a view, and the table is
2034
2054
      not opened yet. Try to open the table.
2035
2055
    */
2068
2088
    {
2069
2089
      if (tables->lock_type == TL_WRITE_DEFAULT)
2070
2090
        tables->table->reginfo.lock_type= update_lock_default;
2071
 
      else if (tables->table->s->tmp_table == NO_TMP_TABLE)
 
2091
      else if (tables->table->s->tmp_table == STANDARD_TABLE)
2072
2092
        tables->table->reginfo.lock_type= tables->lock_type;
2073
2093
    }
2074
2094
  }