~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2011-02-04 09:28:16 UTC
  • mfrom: (2140.1.4 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2144.
  • Revision ID: brian@tangent.org-20110204092816-2s32j9hlh6ztz7ti
Merge in fix for not found table (simplifies the caller as well).

Events are now just being processed on shared tables.

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
 
73
70
/* Functions defined in this cursor */
74
71
 
 
72
void open_table_error(TableShare *share, int error, int db_errno,
 
73
                      myf errortype, int errarg);
 
74
 
75
75
/*************************************************************************/
76
76
 
77
77
// @note this should all be the destructor
82
82
  if (db_stat)
83
83
    error= cursor->close();
84
84
  _alias.clear();
85
 
 
86
85
  if (field)
87
86
  {
88
87
    for (Field **ptr=field ; *ptr ; ptr++)
91
90
    }
92
91
    field= 0;
93
92
  }
94
 
  safe_delete(cursor);
 
93
  delete cursor;
 
94
  cursor= 0;                            /* For easier errorchecking */
95
95
 
96
96
  if (free_share)
97
97
  {
112
112
                       uint32_t db_stat_arg)
113
113
{
114
114
  setShare(share);
115
 
  in_use= session;
116
 
 
117
115
  field= NULL;
118
116
 
119
117
  cursor= NULL;
126
124
  tablenr= 0;
127
125
  db_stat= db_stat_arg;
128
126
 
 
127
  in_use= session;
129
128
  record[0]= (unsigned char *) NULL;
130
129
  record[1]= (unsigned char *) NULL;
131
130
 
197
196
 
198
197
/* Deallocate temporary blob storage */
199
198
 
200
 
void free_blobs(Table *table)
 
199
void free_blobs(register Table *table)
201
200
{
202
201
  uint32_t *ptr, *end;
203
202
  for (ptr= table->getBlobField(), end=ptr + table->sizeBlobFields();
223
222
    
224
223
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
225
224
 
226
 
  List<String>::iterator it(strings.begin());
 
225
  List_iterator<String> it(strings);
227
226
  String *tmp;
228
227
  for (uint32_t i= 0; (tmp= it++); i++)
229
228
  {
239
238
 
240
239
        /* Check that the integer is in the internal */
241
240
 
242
 
int set_zone(int nr, int min_zone, int max_zone)
 
241
int set_zone(register int nr, int min_zone, int max_zone)
243
242
{
244
243
  if (nr<=min_zone)
245
244
    return (min_zone);
323
322
}
324
323
 
325
324
/*
 
325
  Check if database name is valid
 
326
 
 
327
  SYNPOSIS
 
328
    check_db_name()
 
329
    org_name            Name of database and length
 
330
 
 
331
  RETURN
 
332
    false error
 
333
    true ok
 
334
*/
 
335
 
 
336
bool check_db_name(Session *session, identifier::Schema &schema_identifier)
 
337
{
 
338
  if (not plugin::Authorization::isAuthorized(session->user(), schema_identifier))
 
339
  {
 
340
    return false;
 
341
  }
 
342
 
 
343
  return schema_identifier.isValid();
 
344
}
 
345
 
 
346
/*
326
347
  Allow anything as a table name, as long as it doesn't contain an
327
348
  ' ' at the end
328
349
  returns 1 on error
640
661
void Table::setVariableWidth(void)
641
662
{
642
663
  assert(in_use);
643
 
  if (in_use && in_use->getLex()->sql_command == SQLCOM_CREATE_TABLE)
 
664
  if (in_use && in_use->lex->sql_command == SQLCOM_CREATE_TABLE)
644
665
  {
645
666
    getMutableShare()->setVariableWidth();
646
667
    return;
874
895
  blob_count= string_count= null_count= hidden_null_count= group_null_items= 0;
875
896
  param->using_indirect_summary_function= 0;
876
897
 
877
 
  List<Item>::iterator li(fields.begin());
 
898
  List_iterator_fast<Item> li(fields);
878
899
  Item *item;
879
900
  Field **tmp_from_field=from_field;
880
901
  while ((item=li++))
1018
1039
  /* If result table is small; use a heap */
1019
1040
  /* future: storage engine selection can be made dynamic? */
1020
1041
  if (blob_count || using_unique_constraint || 
1021
 
      (session->getLex()->select_lex.options & SELECT_BIG_RESULT) ||
1022
 
      (session->getLex()->current_select->olap == ROLLUP_TYPE) ||
 
1042
      (session->lex->select_lex.options & SELECT_BIG_RESULT) ||
 
1043
      (session->lex->current_select->olap == ROLLUP_TYPE) ||
1023
1044
      (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == OPTION_BIG_TABLES)
1024
1045
  {
1025
1046
    table->getMutableShare()->storage_engine= myisam_engine;
1625
1646
  query_id(0),
1626
1647
  quick_condition_rows(0),
1627
1648
  timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
1628
 
  map(0),
1629
 
  quick_rows(),
1630
 
  const_key_parts(),
1631
 
  quick_key_parts(),
1632
 
  quick_n_ranges()
 
1649
  map(0)
1633
1650
{
1634
1651
  record[0]= (unsigned char *) 0;
1635
1652
  record[1]= (unsigned char *) 0;
 
1653
 
 
1654
  reginfo.reset();
 
1655
  covering_keys.reset();
 
1656
  quick_keys.reset();
 
1657
  merge_keys.reset();
 
1658
 
 
1659
  keys_in_use_for_query.reset();
 
1660
  keys_in_use_for_group_by.reset();
 
1661
  keys_in_use_for_order_by.reset();
 
1662
 
 
1663
  memset(quick_rows, 0, sizeof(ha_rows) * MAX_KEY);
 
1664
  memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
 
1665
 
 
1666
  memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
 
1667
  memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
1636
1668
}
1637
1669
 
1638
1670
/*****************************************************************************
1732
1764
  }
1733
1765
}
1734
1766
 
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
1767
} /* namespace drizzled */