~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Lee Bieber
  • Date: 2010-12-15 16:23:36 UTC
  • mfrom: (1995.1.2 build)
  • Revision ID: kalebral@gmail.com-20101215162336-juntyt4gw4vgohg4
Merge Andrew - fix bug 628912: Crash / segfault in drizzled::Item_func::arguments (this=0x35) at ./drizzled/function/func.h
Merge Andrew - 663919: next query after KILL QUERY will error

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "drizzled/charset.h"
47
47
#include "drizzled/internal/m_string.h"
48
48
#include "plugin/myisam/myisam.h"
49
 
#include "drizzled/plugin/storage_engine.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"
 
57
#include "drizzled/table/instance.h"
61
58
 
62
59
#include "drizzled/table_proto.h"
63
60
 
66
63
namespace drizzled
67
64
{
68
65
 
 
66
extern pid_t current_pid;
69
67
extern plugin::StorageEngine *heap_engine;
70
68
extern plugin::StorageEngine *myisam_engine;
71
69
 
72
70
/* Functions defined in this cursor */
73
71
 
 
72
void open_table_error(TableShare *share, int error, int db_errno,
 
73
                      myf errortype, int errarg);
 
74
 
74
75
/*************************************************************************/
75
76
 
76
77
// @note this should all be the destructor
81
82
  if (db_stat)
82
83
    error= cursor->close();
83
84
  _alias.clear();
84
 
 
85
85
  if (field)
86
86
  {
87
87
    for (Field **ptr=field ; *ptr ; ptr++)
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
 
334
333
    true ok
335
334
*/
336
335
 
337
 
bool check_db_name(Session *session, identifier::Schema &schema_identifier)
 
336
bool check_db_name(Session *session, SchemaIdentifier &schema_identifier)
338
337
{
339
 
  if (not plugin::Authorization::isAuthorized(session->user(), schema_identifier))
 
338
  if (not plugin::Authorization::isAuthorized(session->getSecurityContext(), schema_identifier))
340
339
  {
341
340
    return false;
342
341
  }
522
521
    We must set bit in read set as update_auto_increment() is using the
523
522
    store() to check overflow of auto_increment values
524
523
  */
525
 
  setReadSet(found_next_number_field->position());
526
 
  setWriteSet(found_next_number_field->position());
 
524
  setReadSet(found_next_number_field->field_index);
 
525
  setWriteSet(found_next_number_field->field_index);
527
526
  if (getShare()->next_number_keypart)
528
527
    mark_columns_used_by_index_no_reset(getShare()->next_number_index);
529
528
}
572
571
    for (reg_field= field ; *reg_field ; reg_field++)
573
572
    {
574
573
      if ((*reg_field)->flags & PART_KEY_FLAG)
575
 
        setReadSet((*reg_field)->position());
 
574
        setReadSet((*reg_field)->field_index);
576
575
    }
577
576
  }
578
577
}
621
620
    {
622
621
      /* Merge keys is all keys that had a column refered to in the query */
623
622
      if (is_overlapping(merge_keys, (*reg_field)->part_of_key))
624
 
        setReadSet((*reg_field)->position());
 
623
        setReadSet((*reg_field)->field_index);
625
624
    }
626
625
  }
627
626
 
839
838
    copy_func_count+= param->sum_func_count;
840
839
  }
841
840
 
842
 
  table::Singular *table;
 
841
  table::Instance *table;
843
842
  table= session->getInstanceTable(); // This will not go into the tableshare cache, so no key is used.
844
843
 
845
844
  if (not table->getMemRoot()->multi_alloc_root(0,
885
884
 
886
885
  table->getMutableShare()->blob_field.resize(field_count+1);
887
886
  uint32_t *blob_field= &table->getMutableShare()->blob_field[0];
 
887
  table->getMutableShare()->blob_ptr_size= portable_sizeof_char_ptr;
888
888
  table->getMutableShare()->db_low_byte_first=1;                // True for HEAP and MyISAM
889
889
  table->getMutableShare()->table_charset= param->table_charset;
890
890
  table->getMutableShare()->keys_for_keyread.reset();
965
965
            */
966
966
            (*argp)->maybe_null=1;
967
967
          }
968
 
          new_field->setPosition(fieldnr++);
 
968
          new_field->field_index= fieldnr++;
969
969
        }
970
970
      }
971
971
    }
1012
1012
        group_null_items++;
1013
1013
        new_field->flags|= GROUP_FLAG;
1014
1014
      }
1015
 
      new_field->setPosition(fieldnr++);
 
1015
      new_field->field_index= fieldnr++;
1016
1016
      *(reg_field++)= new_field;
1017
1017
    }
1018
1018
    if (!--hidden_field_count)
1035
1035
  field_count= fieldnr;
1036
1036
  *reg_field= 0;
1037
1037
  *blob_field= 0;                               // End marker
1038
 
  table->getMutableShare()->setFieldSize(field_count);
 
1038
  table->getMutableShare()->fields= field_count;
1039
1039
 
1040
1040
  /* If result table is small; use a heap */
1041
1041
  /* future: storage engine selection can be made dynamic? */
1507
1507
    for (Field **ptr= this->field ; *ptr != NULL; ptr++)
1508
1508
    {
1509
1509
      Field *f= *ptr;
1510
 
      if (write_set->test(f->position()))
 
1510
      if (write_set->test(f->field_index))
1511
1511
      {
1512
1512
        if (f->real_maybe_null())
1513
1513
        {
1540
1540
  /* Compare updated fields */
1541
1541
  for (Field **ptr= field ; *ptr ; ptr++)
1542
1542
  {
1543
 
    if (isWriteSet((*ptr)->position()) &&
 
1543
    if (isWriteSet((*ptr)->field_index) &&
1544
1544
        (*ptr)->cmp_binary_offset(getShare()->rec_buff_length))
1545
1545
      return true;
1546
1546
  }
1647
1647
  query_id(0),
1648
1648
  quick_condition_rows(0),
1649
1649
  timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
1650
 
  map(0),
1651
 
  quick_rows(),
1652
 
  const_key_parts(),
1653
 
  quick_key_parts(),
1654
 
  quick_n_ranges()
 
1650
  map(0)
1655
1651
{
1656
1652
  record[0]= (unsigned char *) 0;
1657
1653
  record[1]= (unsigned char *) 0;
 
1654
 
 
1655
  reginfo.reset();
 
1656
  covering_keys.reset();
 
1657
  quick_keys.reset();
 
1658
  merge_keys.reset();
 
1659
 
 
1660
  keys_in_use_for_query.reset();
 
1661
  keys_in_use_for_group_by.reset();
 
1662
  keys_in_use_for_order_by.reset();
 
1663
 
 
1664
  memset(quick_rows, 0, sizeof(ha_rows) * MAX_KEY);
 
1665
  memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
 
1666
 
 
1667
  memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
 
1668
  memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
1658
1669
}
1659
1670
 
1660
1671
/*****************************************************************************
1676
1687
    print them to the .err log
1677
1688
  */
1678
1689
  if (error != HA_ERR_LOCK_DEADLOCK && error != HA_ERR_LOCK_WAIT_TIMEOUT)
1679
 
    errmsg_printf(error::ERROR, _("Got error %d when reading table '%s'"),
 
1690
    errmsg_printf(ERRMSG_LVL_ERROR, _("Got error %d when reading table '%s'"),
1680
1691
                  error, getShare()->getPath());
1681
1692
  print_error(error, MYF(0));
1682
1693
 
1754
1765
  }
1755
1766
}
1756
1767
 
1757
 
/*
1758
 
  Is this instance of the table should be reopen or represents a name-lock?
1759
 
*/
1760
 
bool Table::needs_reopen_or_name_lock() const
1761
 
1762
 
  return getShare()->getVersion() != refresh_version;
1763
 
}
1764
 
 
1765
 
uint32_t Table::index_flags(uint32_t idx) const
1766
 
{
1767
 
  return getShare()->getEngine()->index_flags(getShare()->getKeyInfo(idx).algorithm);
1768
 
}
1769
 
 
1770
 
void Table::print_error(int error, myf errflag) const
1771
 
{
1772
 
  getShare()->getEngine()->print_error(error, errflag, *this);
1773
 
}
1774
 
 
1775
1768
} /* namespace drizzled */