~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_update.cc

  • Committer: Brian Aker
  • Date: 2008-08-16 22:34:15 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816223415-n24esdpfcqi4pwpy
Refactor around classes. TABLE_LIST has been factored out of table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
/* Return 0 if row hasn't changed */
26
26
 
27
 
bool compare_record(TABLE *table)
 
27
bool compare_record(Table *table)
28
28
{
29
29
  if (table->s->blob_fields + table->s->varchar_fields == 0)
30
30
    return cmp_record(table,record[1]);
93
93
  @param[in] table   table
94
94
*/
95
95
 
96
 
static void prepare_record_for_error_message(int error, TABLE *table)
 
96
static void prepare_record_for_error_message(int error, Table *table)
97
97
{
98
98
  Field **field_p;
99
99
  Field *field;
190
190
  uint          table_count= 0;
191
191
  ha_rows       updated, found;
192
192
  key_map       old_covering_keys;
193
 
  TABLE         *table;
 
193
  Table         *table;
194
194
  SQL_SELECT    *select;
195
195
  READ_RECORD   info;
196
196
  SELECT_LEX    *select_lex= &thd->lex->select_lex;
892
892
  leaves= lex->select_lex.leaf_tables;
893
893
  for (tl= leaves; tl; tl= tl->next_leaf)
894
894
  {
895
 
    TABLE *table= tl->table;
 
895
    Table *table= tl->table;
896
896
    /* Only set timestamp column if this is not modified */
897
897
    if (table->timestamp_field &&
898
898
        bitmap_is_set(table->write_set,
917
917
      */
918
918
      tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ;
919
919
      tl->updating= 0;
920
 
      /* Update TABLE::lock_type accordingly. */
 
920
      /* Update Table::lock_type accordingly. */
921
921
      if (!tl->placeholder() && !using_lock_tables)
922
922
        tl->table->reginfo.lock_type= tl->lock_type;
923
923
    }
1088
1088
  for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf)
1089
1089
  {
1090
1090
    /* TODO: add support of view of join support */
1091
 
    TABLE *table=table_ref->table;
 
1091
    Table *table=table_ref->table;
1092
1092
    leaf_table_count++;
1093
1093
    if (tables_to_update & table->map)
1094
1094
    {
1108
1108
  table_count=  update.elements;
1109
1109
  update_tables= (TABLE_LIST*) update.first;
1110
1110
 
1111
 
  tmp_tables = (TABLE**) thd->calloc(sizeof(TABLE *) * table_count);
 
1111
  tmp_tables = (Table**) thd->calloc(sizeof(Table *) * table_count);
1112
1112
  tmp_table_param = (TMP_TABLE_PARAM*) thd->calloc(sizeof(TMP_TABLE_PARAM) *
1113
1113
                                                   table_count);
1114
1114
  fields_for_table= (List_item **) thd->alloc(sizeof(List_item *) *
1169
1169
    - Table is not joined to itself.
1170
1170
 
1171
1171
    This function gets information about fields to be updated from
1172
 
    the TABLE::write_set bitmap.
 
1172
    the Table::write_set bitmap.
1173
1173
 
1174
1174
  WARNING
1175
1175
    This code is a bit dependent of how make_join_readinfo() works.
1182
1182
static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab,
1183
1183
                               TABLE_LIST *table_ref, TABLE_LIST *all_tables)
1184
1184
{
1185
 
  TABLE *table= join_tab->table;
 
1185
  Table *table= join_tab->table;
1186
1186
  if (unique_table(thd, table_ref, all_tables, 0))
1187
1187
    return 0;
1188
1188
  switch (join_tab->type) {
1235
1235
  /* Create a temporary table for keys to all tables, except main table */
1236
1236
  for (table_ref= update_tables; table_ref; table_ref= table_ref->next_local)
1237
1237
  {
1238
 
    TABLE *table=table_ref->table;
 
1238
    Table *table=table_ref->table;
1239
1239
    uint cnt= table_ref->shared;
1240
1240
    List<Item> temp_fields;
1241
1241
    ORDER     group;
1264
1264
      OPTION condition.
1265
1265
    */
1266
1266
 
1267
 
    List_iterator_fast<TABLE> tbl_it(unupdated_check_opt_tables);
1268
 
    TABLE *tbl= table;
 
1267
    List_iterator_fast<Table> tbl_it(unupdated_check_opt_tables);
 
1268
    Table *tbl= table;
1269
1269
    do
1270
1270
    {
1271
1271
      Field_string *field= new Field_string(tbl->file->ref_length, 0,
1349
1349
  
1350
1350
  for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
1351
1351
  {
1352
 
    TABLE *table= cur_table->table;
 
1352
    Table *table= cur_table->table;
1353
1353
    uint offset= cur_table->shared;
1354
1354
    /*
1355
1355
      Check if we are using outer join and we didn't find the row
1441
1441
    else
1442
1442
    {
1443
1443
      int error;
1444
 
      TABLE *tmp_table= tmp_tables[offset];
 
1444
      Table *tmp_table= tmp_tables[offset];
1445
1445
      /*
1446
1446
       For updatable VIEW store rowid of the updated table and
1447
1447
       rowids of tables used in the CHECK OPTION condition.
1448
1448
      */
1449
1449
      uint field_num= 0;
1450
 
      List_iterator_fast<TABLE> tbl_it(unupdated_check_opt_tables);
1451
 
      TABLE *tbl= table;
 
1450
      List_iterator_fast<Table> tbl_it(unupdated_check_opt_tables);
 
1451
      Table *tbl= table;
1452
1452
      do
1453
1453
      {
1454
1454
        tbl->file->position(tbl->record[0]);
1542
1542
  TABLE_LIST *cur_table;
1543
1543
  int local_error= 0;
1544
1544
  ha_rows org_updated;
1545
 
  TABLE *table, *tmp_table;
1546
 
  List_iterator_fast<TABLE> check_opt_it(unupdated_check_opt_tables);
 
1545
  Table *table, *tmp_table;
 
1546
  List_iterator_fast<Table> check_opt_it(unupdated_check_opt_tables);
1547
1547
  
1548
1548
  do_update= 0;                                 // Don't retry this function
1549
1549
  if (!found)
1563
1563
    table->file->extra(HA_EXTRA_NO_CACHE);
1564
1564
 
1565
1565
    check_opt_it.rewind();
1566
 
    while(TABLE *tbl= check_opt_it++)
 
1566
    while(Table *tbl= check_opt_it++)
1567
1567
    {
1568
1568
      if (tbl->file->ha_rnd_init(1))
1569
1569
        goto err;
1607
1607
 
1608
1608
      /* call rnd_pos() using rowids from temporary table */
1609
1609
      check_opt_it.rewind();
1610
 
      TABLE *tbl= table;
 
1610
      Table *tbl= table;
1611
1611
      uint field_num= 0;
1612
1612
      do
1613
1613
      {
1657
1657
    (void) table->file->ha_rnd_end();
1658
1658
    (void) tmp_table->file->ha_rnd_end();
1659
1659
    check_opt_it.rewind();
1660
 
    while (TABLE *tbl= check_opt_it++)
 
1660
    while (Table *tbl= check_opt_it++)
1661
1661
        tbl->file->ha_rnd_end();
1662
1662
 
1663
1663
  }
1672
1672
  (void) table->file->ha_rnd_end();
1673
1673
  (void) tmp_table->file->ha_rnd_end();
1674
1674
  check_opt_it.rewind();
1675
 
  while (TABLE *tbl= check_opt_it++)
 
1675
  while (Table *tbl= check_opt_it++)
1676
1676
      tbl->file->ha_rnd_end();
1677
1677
 
1678
1678
  if (updated != org_updated)