~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_update.cc

  • Committer: Brian Aker
  • Date: 2009-06-08 16:51:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1058.
  • Revision ID: brian@gaz-20090608165122-4zvh22zgsaqadcjy
Remove lock_tables list from session.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
using namespace std;
31
31
 
32
 
/*
33
 
  check that all fields are real fields
34
 
 
35
 
  SYNOPSIS
36
 
    check_fields()
37
 
    session             thread handler
38
 
    items           Items for check
39
 
 
40
 
  RETURN
41
 
    true  Items can't be used in UPDATE
42
 
    false Items are OK
43
 
*/
44
 
 
45
 
static bool check_fields(Session *session, List<Item> &items)
46
 
{
47
 
  List_iterator<Item> it(items);
48
 
  Item *item;
49
 
  Item_field *field;
50
 
 
51
 
  while ((item= it++))
52
 
  {
53
 
    if (!(field= item->filed_for_view_update()))
54
 
    {
55
 
      /* item has name, because it comes from VIEW SELECT list */
56
 
      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
57
 
      return true;
58
 
    }
59
 
    /*
60
 
      we make temporary copy of Item_field, to avoid influence of changing
61
 
      result_field on Item_ref which refer on this field
62
 
    */
63
 
    session->change_item_tree(it.ref(), new Item_field(session, field));
64
 
  }
65
 
  return false;
66
 
}
67
 
 
68
32
 
69
33
/**
70
34
  Re-read record if more columns are needed for error message.
796
760
  TableList *tl, *leaves;
797
761
  List<Item> *fields= &lex->select_lex.item_list;
798
762
  table_map tables_for_update;
799
 
  bool update_view= 0;
800
763
  /*
801
764
    if this multi-update was converted from usual update, here is table
802
765
    counter else junk will be assigned here, but then replaced with real
803
766
    count in open_tables()
804
767
  */
805
768
  uint32_t  table_count= lex->table_count;
806
 
  const bool using_lock_tables= session->locked_tables != 0;
807
769
  bool original_multiupdate= (session->lex->sql_command == SQLCOM_UPDATE_MULTI);
808
770
  bool need_reopen= false;
809
771
 
833
795
  if (setup_fields_with_no_wrap(session, 0, *fields, MARK_COLUMNS_WRITE, 0, 0))
834
796
    return true;
835
797
 
836
 
  if (update_view && check_fields(session, *fields))
837
 
  {
838
 
    return true;
839
 
  }
840
 
 
841
798
  tables_for_update= get_table_map(fields);
842
799
 
843
800
  /*
870
827
      tl->lock_type= TL_READ;
871
828
      tl->updating= 0;
872
829
      /* Update Table::lock_type accordingly. */
873
 
      if (!tl->placeholder() && !using_lock_tables)
 
830
      if (!tl->placeholder())
874
831
        tl->table->reginfo.lock_type= tl->lock_type;
875
832
    }
876
833
  }