~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Stewart Smith
  • Date: 2011-02-10 01:03:48 UTC
  • mto: (2154.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2155.
  • Revision ID: stewart@flamingspork.com-20110210010348-5l0zh0akjahvx3vi
fix Session::tx_isolation to be getTxIsolation to follow coding style, but look weird

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
 
67
63
namespace drizzled
68
64
{
69
65
 
 
66
extern pid_t current_pid;
70
67
extern plugin::StorageEngine *heap_engine;
71
68
extern plugin::StorageEngine *myisam_engine;
72
69
 
91
88
    }
92
89
    field= 0;
93
90
  }
94
 
  safe_delete(cursor);
 
91
  delete cursor;
 
92
  cursor= 0;                            /* For easier errorchecking */
95
93
 
96
94
  if (free_share)
97
95
  {
197
195
 
198
196
/* Deallocate temporary blob storage */
199
197
 
200
 
void free_blobs(Table *table)
 
198
void free_blobs(register Table *table)
201
199
{
202
200
  uint32_t *ptr, *end;
203
201
  for (ptr= table->getBlobField(), end=ptr + table->sizeBlobFields();
223
221
    
224
222
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
225
223
 
226
 
  List<String>::iterator it(strings.begin());
 
224
  List_iterator<String> it(strings);
227
225
  String *tmp;
228
226
  for (uint32_t i= 0; (tmp= it++); i++)
229
227
  {
239
237
 
240
238
        /* Check that the integer is in the internal */
241
239
 
242
 
int set_zone(int nr, int min_zone, int max_zone)
 
240
int set_zone(register int nr, int min_zone, int max_zone)
243
241
{
244
242
  if (nr<=min_zone)
245
243
    return (min_zone);
323
321
}
324
322
 
325
323
/*
 
324
  Check if database name is valid
 
325
 
 
326
  SYNPOSIS
 
327
    check_db_name()
 
328
    org_name            Name of database and length
 
329
 
 
330
  RETURN
 
331
    false error
 
332
    true ok
 
333
*/
 
334
 
 
335
bool check_db_name(Session *session, identifier::Schema &schema_identifier)
 
336
{
 
337
  if (not plugin::Authorization::isAuthorized(session->user(), schema_identifier))
 
338
  {
 
339
    return false;
 
340
  }
 
341
 
 
342
  return schema_identifier.isValid();
 
343
}
 
344
 
 
345
/*
326
346
  Allow anything as a table name, as long as it doesn't contain an
327
347
  ' ' at the end
328
348
  returns 1 on error
640
660
void Table::setVariableWidth(void)
641
661
{
642
662
  assert(in_use);
643
 
  if (in_use && in_use->getLex()->sql_command == SQLCOM_CREATE_TABLE)
 
663
  if (in_use && in_use->lex->sql_command == SQLCOM_CREATE_TABLE)
644
664
  {
645
665
    getMutableShare()->setVariableWidth();
646
666
    return;
874
894
  blob_count= string_count= null_count= hidden_null_count= group_null_items= 0;
875
895
  param->using_indirect_summary_function= 0;
876
896
 
877
 
  List<Item>::iterator li(fields.begin());
 
897
  List_iterator_fast<Item> li(fields);
878
898
  Item *item;
879
899
  Field **tmp_from_field=from_field;
880
900
  while ((item=li++))
1018
1038
  /* If result table is small; use a heap */
1019
1039
  /* future: storage engine selection can be made dynamic? */
1020
1040
  if (blob_count || using_unique_constraint || 
1021
 
      (session->getLex()->select_lex.options & SELECT_BIG_RESULT) ||
1022
 
      (session->getLex()->current_select->olap == ROLLUP_TYPE) ||
 
1041
      (session->lex->select_lex.options & SELECT_BIG_RESULT) ||
 
1042
      (session->lex->current_select->olap == ROLLUP_TYPE) ||
1023
1043
      (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == OPTION_BIG_TABLES)
1024
1044
  {
1025
1045
    table->getMutableShare()->storage_engine= myisam_engine;
1732
1752
  }
1733
1753
}
1734
1754
 
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
1755
} /* namespace drizzled */