~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

Merged remove-dead-find_field_in_table_sef into remove-dead-Item-save_in_field_no_warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <drizzled/item/int.h>
34
34
#include <drizzled/item/empty_string.h>
35
35
#include <drizzled/replication_services.h>
 
36
#include "drizzled/transaction_services.h"
36
37
#include <drizzled/table_proto.h>
37
38
#include <drizzled/plugin/client.h>
38
39
#include <drizzled/table_identifier.h>
50
51
#include <sstream>
51
52
 
52
53
using namespace std;
53
 
using namespace drizzled;
 
54
 
 
55
namespace drizzled
 
56
{
54
57
 
55
58
extern pid_t current_pid;
56
59
 
181
184
    to[length]= hexchars[(*from) & 15];
182
185
  }
183
186
 
184
 
  if (check_if_legal_tablename(to) &&
 
187
  if (internal::check_if_legal_tablename(to) &&
185
188
      length + 4 < to_length)
186
189
  {
187
190
    memcpy(to + length, "@@@", 4);
318
321
  if (bufflen < path_str.str().length())
319
322
    length= 0;
320
323
  else
321
 
    length= unpack_filename(buff, path_str.str().c_str());
 
324
    length= internal::unpack_filename(buff, path_str.str().c_str());
322
325
 
323
326
  return length;
324
327
}
1443
1446
    return(true);
1444
1447
  }
1445
1448
  /* Sort keys in optimized order */
1446
 
  my_qsort((unsigned char*) *key_info_buffer, *key_count, sizeof(KEY),
1447
 
           (qsort_cmp) sort_keys);
 
1449
  internal::my_qsort((unsigned char*) *key_info_buffer, *key_count, sizeof(KEY),
 
1450
                     (qsort_cmp) sort_keys);
1448
1451
 
1449
1452
  /* Check fields. */
1450
1453
  it.rewind();
1563
1566
  bool          error= true;
1564
1567
  TableShare share;
1565
1568
  bool lex_identified_temp_table=
1566
 
    (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1569
    (table_proto->type() == message::Table::TEMPORARY);
1567
1570
 
1568
1571
  /* Check for duplicate fields and check type of table to create */
1569
1572
  if (!alter_info->create_list.elements)
1736
1739
  Table *name_lock= NULL;
1737
1740
  bool result;
1738
1741
  bool lex_identified_temp_table=
1739
 
    (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1742
    (table_proto->type() == message::Table::TEMPORARY);
1740
1743
 
1741
1744
  if (! lex_identified_temp_table)
1742
1745
  {
1820
1823
  for (uint32_t i=2 ; i< 100; i++)
1821
1824
  {
1822
1825
    *buff_end= '_';
1823
 
    int10_to_str(i, buff_end+1, 10);
 
1826
    internal::int10_to_str(i, buff_end+1, 10);
1824
1827
    if (!check_if_keyname_exists(buff,start,end))
1825
1828
      return memory::sql_strdup(buff);
1826
1829
  }
1975
1978
  Item *item;
1976
1979
  LEX *lex= session->lex;
1977
1980
  int result_code= 0;
 
1981
  TransactionServices &transaction_services= TransactionServices::singleton();
1978
1982
  const CHARSET_INFO * const cs= system_charset_info;
1979
1983
 
1980
1984
  if (! session->endActiveTransaction())
2052
2056
      length= snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY),
2053
2057
                       table_name);
2054
2058
      session->client->store(buff, length);
2055
 
      ha_autocommit_or_rollback(session, 0);
 
2059
      transaction_services.ha_autocommit_or_rollback(session, false);
2056
2060
      session->endTransaction(COMMIT);
2057
2061
      session->close_thread_tables();
2058
2062
      lex->reset_query_tables_list(false);
2175
2179
        }
2176
2180
      }
2177
2181
    }
2178
 
    ha_autocommit_or_rollback(session, 0);
 
2182
    transaction_services.ha_autocommit_or_rollback(session, false);
2179
2183
    session->endTransaction(COMMIT);
2180
2184
    session->close_thread_tables();
2181
2185
    table->table=0;                             // For query cache
2187
2191
  return(false);
2188
2192
 
2189
2193
err:
2190
 
  ha_autocommit_or_rollback(session, 1);
 
2194
  transaction_services.ha_autocommit_or_rollback(session, true);
2191
2195
  session->endTransaction(ROLLBACK);
2192
2196
  session->close_thread_tables();                       // Shouldn't be needed
2193
2197
  if (table)
2211
2215
*/
2212
2216
 
2213
2217
bool mysql_create_like_table(Session* session, TableList* table, TableList* src_table,
2214
 
                             drizzled::message::Table& create_table_proto,
2215
 
                             drizzled::plugin::StorageEngine *engine_arg,
 
2218
                             message::Table& create_table_proto,
 
2219
                             plugin::StorageEngine *engine_arg,
2216
2220
                             bool is_if_not_exists,
2217
2221
                             bool is_engine_set)
2218
2222
{
2225
2229
  uint32_t not_used;
2226
2230
  message::Table src_proto;
2227
2231
  bool lex_identified_temp_table=
2228
 
    (create_table_proto.type() == drizzled::message::Table::TEMPORARY);
 
2232
    (create_table_proto.type() == message::Table::TEMPORARY);
2229
2233
 
2230
2234
  /*
2231
2235
    By opening source table we guarantee that it exists and no concurrent
2532
2536
      else
2533
2537
      {
2534
2538
        /* calculating table's checksum */
2535
 
        ha_checksum crc= 0;
 
2539
        internal::ha_checksum crc= 0;
2536
2540
        unsigned char null_mask=256 -  (1 << t->s->last_null_bit_pos);
2537
2541
 
2538
2542
        t->use_all_columns();
2543
2547
        {
2544
2548
          for (;;)
2545
2549
          {
2546
 
            ha_checksum row_crc= 0;
 
2550
            internal::ha_checksum row_crc= 0;
2547
2551
            int error= t->cursor->rnd_next(t->record[0]);
2548
2552
            if (unlikely(error))
2549
2553
            {
2558
2562
              if (!(t->s->db_create_options & HA_OPTION_PACK_RECORD))
2559
2563
                t->record[0][0] |= 1;
2560
2564
 
2561
 
              row_crc= my_checksum(row_crc, t->record[0], t->s->null_bytes);
 
2565
              row_crc= internal::my_checksum(row_crc, t->record[0], t->s->null_bytes);
2562
2566
            }
2563
2567
 
2564
2568
            for (uint32_t i= 0; i < t->s->fields; i++ )
2569
2573
              {
2570
2574
                String tmp;
2571
2575
                f->val_str(&tmp);
2572
 
                row_crc= my_checksum(row_crc, (unsigned char*) tmp.ptr(), tmp.length());
 
2576
                row_crc= internal::my_checksum(row_crc, (unsigned char*) tmp.ptr(), tmp.length());
2573
2577
              }
2574
2578
              else
2575
 
                row_crc= my_checksum(row_crc, f->ptr,
 
2579
                row_crc= internal::my_checksum(row_crc, f->ptr,
2576
2580
                                     f->pack_length());
2577
2581
            }
2578
2582
 
2599
2603
    table->table=0;
2600
2604
  return(true);
2601
2605
}
 
2606
 
 
2607
} /* namespace drizzled */