~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_update.cc

  • Committer: Monty Taylor
  • Date: 2009-01-09 07:02:24 UTC
  • mto: (779.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 784.
  • Revision ID: mordred@inaugust.com-20090109070224-prwl5p52mfql3zfw
Split out readline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
 
147
147
  RETURN
148
148
    0  - OK
 
149
    2  - privilege check and openning table passed, but we need to convert to
 
150
         multi-update because of view substitution
149
151
    1  - error
150
152
*/
151
153
 
168
170
  Table         *table;
169
171
  SQL_SELECT    *select;
170
172
  READ_RECORD   info;
171
 
  Select_Lex    *select_lex= &session->lex->select_lex;
 
173
  SELECT_LEX    *select_lex= &session->lex->select_lex;
172
174
  bool          need_reopen;
173
175
  uint64_t     id;
174
176
  List<Item> all_fields;
267
269
    if (error)
268
270
      goto abort;                               // Error in where
269
271
    DRIZZLE_UPDATE_END();
270
 
    session->my_ok();                           // No matching records
 
272
    my_ok(session);                             // No matching records
271
273
    return(0);
272
274
  }
273
275
  if (!select && limit != HA_POS_ERROR)
686
688
            (ulong) session->cuted_fields);
687
689
    session->row_count_func=
688
690
      (session->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
689
 
    session->my_ok((ulong) session->row_count_func, id, buff);
 
691
    my_ok(session, (ulong) session->row_count_func, id, buff);
690
692
  }
691
693
  session->count_cuted_fields= CHECK_FIELD_IGNORE;              /* calc cuted fields */
692
694
  session->abort_on_warning= 0;
726
728
                         Item **conds, uint32_t order_num, order_st *order)
727
729
{
728
730
  List<Item> all_fields;
729
 
  Select_Lex *select_lex= &session->lex->select_lex;
 
731
  SELECT_LEX *select_lex= &session->lex->select_lex;
730
732
 
731
733
  session->lex->allow_sum_func= 0;
732
734
 
739
741
      select_lex->setup_ref_array(session, order_num) ||
740
742
      setup_order(session, select_lex->ref_pointer_array,
741
743
                  table_list, all_fields, all_fields, order))
742
 
    return true;
 
744
    return(true);
743
745
 
744
746
  /* Check that we are not using table that we are updating in a sub select */
745
747
  {
748
750
    {
749
751
      update_non_unique_table_error(table_list, "UPDATE", duplicate);
750
752
      my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
751
 
      return true;
 
753
      return(true);
752
754
    }
753
755
  }
754
756
 
755
 
  return false;
 
757
  return(false);
756
758
}
757
759
 
758
760
 
816
818
  if (((original_multiupdate || need_reopen) &&
817
819
       open_tables(session, &table_list, &table_count, 0)) ||
818
820
      mysql_handle_derived(lex, &mysql_derived_prepare))
819
 
    return true;
 
821
    return(true);
820
822
  /*
821
823
    setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
822
824
    second time, but this call will do nothing (there are check for second
827
829
                                    &lex->select_lex.top_join_list,
828
830
                                    table_list,
829
831
                                    &lex->select_lex.leaf_tables, false))
830
 
    return true;
 
832
    return(true);
831
833
 
832
834
  if (setup_fields_with_no_wrap(session, 0, *fields, MARK_COLUMNS_WRITE, 0, 0))
833
 
    return true;
 
835
    return(true);
834
836
 
835
837
  if (update_view && check_fields(session, *fields))
836
838
  {
837
 
    return true;
 
839
    return(true);
838
840
  }
839
841
 
840
842
  tables_for_update= get_table_map(fields);
880
882
  if (lock_tables(session, table_list, table_count, &need_reopen))
881
883
  {
882
884
    if (!need_reopen)
883
 
      return true;
 
885
      return(true);
884
886
 
885
887
    /*
886
888
      We have to reopen tables since some of them were altered or dropped
916
918
      if ((duplicate= unique_table(session, tl, table_list, 0)))
917
919
      {
918
920
        update_non_unique_table_error(table_list, "UPDATE", duplicate);
919
 
        return true;
 
921
        return(true);
920
922
      }
921
923
    }
922
924
  }
928
930
 
929
931
  if (session->fill_derived_tables() &&
930
932
      mysql_handle_derived(lex, &mysql_derived_filling))
931
 
    return true;
 
933
    return(true);
932
934
 
933
935
  return (false);
934
936
}
945
947
                        COND *conds,
946
948
                        uint64_t options,
947
949
                        enum enum_duplicates handle_duplicates, bool ignore,
948
 
                        Select_Lex_Unit *unit, Select_Lex *select_lex)
 
950
                        SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex)
949
951
{
950
952
  multi_update *result;
951
953
  bool res;
954
956
                                 session->lex->select_lex.leaf_tables,
955
957
                                 fields, values,
956
958
                                 handle_duplicates, ignore)))
957
 
    return true;
 
959
    return(true);
958
960
 
959
961
  session->abort_on_warning= true;
960
962
 
963
965
                      table_list, select_lex->with_wild,
964
966
                      total_list,
965
967
                      conds, 0, (order_st *) NULL, (order_st *)NULL, (Item *) NULL,
 
968
                      (order_st *)NULL,
966
969
                      options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
967
970
                      OPTION_SETUP_TABLES_DONE,
968
971
                      result, unit, select_lex);
975
978
  }
976
979
  delete result;
977
980
  session->abort_on_warning= 0;
978
 
  return false;
 
981
  return(false);
979
982
}
980
983
 
981
984
 
997
1000
*/
998
1001
 
999
1002
int multi_update::prepare(List<Item> &,
1000
 
                          Select_Lex_Unit *)
 
1003
                          SELECT_LEX_UNIT *)
1001
1004
{
1002
1005
  TableList *table_ref;
1003
1006
  SQL_LIST update;
1059
1062
  update_tables= (TableList*) update.first;
1060
1063
 
1061
1064
  tmp_tables = (Table**) session->calloc(sizeof(Table *) * table_count);
1062
 
  tmp_table_param = (Tmp_Table_Param*) session->calloc(sizeof(Tmp_Table_Param) *
 
1065
  tmp_table_param = (TMP_TABLE_PARAM*) session->calloc(sizeof(TMP_TABLE_PARAM) *
1063
1066
                                                   table_count);
1064
1067
  fields_for_table= (List_item **) session->alloc(sizeof(List_item *) *
1065
1068
                                              table_count);
1189
1192
    uint32_t cnt= table_ref->shared;
1190
1193
    List<Item> temp_fields;
1191
1194
    order_st     group;
1192
 
    Tmp_Table_Param *tmp_param;
 
1195
    TMP_TABLE_PARAM *tmp_param;
1193
1196
 
1194
1197
    table->mark_columns_needed_for_update();
1195
1198
    if (ignore)
1671
1674
    /* Safety: If we haven't got an error before (can happen in do_updates) */
1672
1675
    my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update",
1673
1676
               MYF(0));
1674
 
    return true;
 
1677
    return(true);
1675
1678
  }
1676
1679
 
1677
1680
  id= session->arg_of_last_insert_id_function ?
1680
1683
          (ulong) session->cuted_fields);
1681
1684
  session->row_count_func=
1682
1685
    (session->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
1683
 
  session->my_ok((ulong) session->row_count_func, id, buff);
1684
 
 
1685
 
  return false;
 
1686
  ::my_ok(session, (ulong) session->row_count_func, id, buff);
 
1687
  return(false);
1686
1688
}