~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Lee Bieber
  • Date: 2011-02-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
/* Some general useful functions */
18
18
 
19
 
#include <config.h>
 
19
#include "config.h"
20
20
 
21
21
#include <float.h>
22
22
#include <fcntl.h>
28
28
#include <drizzled/error.h>
29
29
#include <drizzled/gettext.h>
30
30
 
31
 
#include <drizzled/plugin/transactional_storage_engine.h>
32
 
#include <drizzled/plugin/authorization.h>
 
31
#include "drizzled/plugin/transactional_storage_engine.h"
 
32
#include "drizzled/plugin/authorization.h"
33
33
#include <drizzled/nested_join.h>
34
34
#include <drizzled/sql_parse.h>
35
35
#include <drizzled/item/sum.h>
42
42
#include <drizzled/field/double.h>
43
43
#include <drizzled/unireg.h>
44
44
#include <drizzled/message/table.pb.h>
45
 
#include <drizzled/sql_table.h>
46
 
#include <drizzled/charset.h>
47
 
#include <drizzled/internal/m_string.h>
48
 
#include <plugin/myisam/myisam.h>
49
 
#include <drizzled/plugin/storage_engine.h>
 
45
#include "drizzled/sql_table.h"
 
46
#include "drizzled/charset.h"
 
47
#include "drizzled/internal/m_string.h"
 
48
#include "plugin/myisam/myisam.h"
50
49
 
51
50
#include <drizzled/item/string.h>
52
51
#include <drizzled/item/int.h>
55
54
#include <drizzled/item/null.h>
56
55
#include <drizzled/temporal.h>
57
56
 
58
 
#include <drizzled/refresh_version.h>
59
 
 
60
 
#include <drizzled/table/singular.h>
61
 
 
62
 
#include <drizzled/table_proto.h>
63
 
#include <drizzled/typelib.h>
 
57
#include "drizzled/table/singular.h"
 
58
 
 
59
#include "drizzled/table_proto.h"
64
60
 
65
61
using namespace std;
66
62
 
91
87
    }
92
88
    field= 0;
93
89
  }
94
 
  safe_delete(cursor);
 
90
  delete cursor;
 
91
  cursor= 0;                            /* For easier errorchecking */
95
92
 
96
93
  if (free_share)
97
94
  {
197
194
 
198
195
/* Deallocate temporary blob storage */
199
196
 
200
 
void free_blobs(Table *table)
 
197
void free_blobs(register Table *table)
201
198
{
202
199
  uint32_t *ptr, *end;
203
200
  for (ptr= table->getBlobField(), end=ptr + table->sizeBlobFields();
223
220
    
224
221
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
225
222
 
226
 
  List<String>::iterator it(strings.begin());
 
223
  List_iterator<String> it(strings);
227
224
  String *tmp;
228
225
  for (uint32_t i= 0; (tmp= it++); i++)
229
226
  {
239
236
 
240
237
        /* Check that the integer is in the internal */
241
238
 
242
 
int set_zone(int nr, int min_zone, int max_zone)
 
239
int set_zone(register int nr, int min_zone, int max_zone)
243
240
{
244
241
  if (nr<=min_zone)
245
242
    return (min_zone);
323
320
}
324
321
 
325
322
/*
 
323
  Check if database name is valid
 
324
 
 
325
  SYNPOSIS
 
326
    check_db_name()
 
327
    org_name            Name of database and length
 
328
 
 
329
  RETURN
 
330
    false error
 
331
    true ok
 
332
*/
 
333
 
 
334
bool check_db_name(Session *session, identifier::Schema &schema_identifier)
 
335
{
 
336
  if (not plugin::Authorization::isAuthorized(session->user(), schema_identifier))
 
337
  {
 
338
    return false;
 
339
  }
 
340
 
 
341
  return schema_identifier.isValid();
 
342
}
 
343
 
 
344
/*
326
345
  Allow anything as a table name, as long as it doesn't contain an
327
346
  ' ' at the end
328
347
  returns 1 on error
640
659
void Table::setVariableWidth(void)
641
660
{
642
661
  assert(in_use);
643
 
  if (in_use && in_use->getLex()->sql_command == SQLCOM_CREATE_TABLE)
 
662
  if (in_use && in_use->lex->sql_command == SQLCOM_CREATE_TABLE)
644
663
  {
645
664
    getMutableShare()->setVariableWidth();
646
665
    return;
874
893
  blob_count= string_count= null_count= hidden_null_count= group_null_items= 0;
875
894
  param->using_indirect_summary_function= 0;
876
895
 
877
 
  List<Item>::iterator li(fields.begin());
 
896
  List_iterator_fast<Item> li(fields);
878
897
  Item *item;
879
898
  Field **tmp_from_field=from_field;
880
899
  while ((item=li++))
1018
1037
  /* If result table is small; use a heap */
1019
1038
  /* future: storage engine selection can be made dynamic? */
1020
1039
  if (blob_count || using_unique_constraint || 
1021
 
      (session->getLex()->select_lex.options & SELECT_BIG_RESULT) ||
1022
 
      (session->getLex()->current_select->olap == ROLLUP_TYPE) ||
 
1040
      (session->lex->select_lex.options & SELECT_BIG_RESULT) ||
 
1041
      (session->lex->current_select->olap == ROLLUP_TYPE) ||
1023
1042
      (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == OPTION_BIG_TABLES)
1024
1043
  {
1025
1044
    table->getMutableShare()->storage_engine= myisam_engine;
1732
1751
  }
1733
1752
}
1734
1753
 
1735
 
/*
1736
 
  Is this instance of the table should be reopen or represents a name-lock?
1737
 
*/
1738
 
bool Table::needs_reopen_or_name_lock() const
1739
 
1740
 
  return getShare()->getVersion() != refresh_version;
1741
 
}
1742
 
 
1743
 
uint32_t Table::index_flags(uint32_t idx) const
1744
 
{
1745
 
  return getShare()->getEngine()->index_flags(getShare()->getKeyInfo(idx).algorithm);
1746
 
}
1747
 
 
1748
 
void Table::print_error(int error, myf errflag) const
1749
 
{
1750
 
  getShare()->getEngine()->print_error(error, errflag, *this);
1751
 
}
1752
 
 
1753
1754
} /* namespace drizzled */