~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to sql/sql_update.cc

  • Committer: sasha at sashanet
  • Date: 2001-04-12 01:09:00 UTC
  • mfrom: (669.1.1)
  • Revision ID: sp1r-sasha@mysql.sashanet.com-20010412010900-14282
Ugly merge of 3.23 changes into 4.0 - fix up needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2
 
   
 
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
5
5
   the Free Software Foundation; either version 2 of the License, or
6
6
   (at your option) any later version.
7
 
   
 
7
 
8
8
   This program is distributed in the hope that it will be useful,
9
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
   GNU General Public License for more details.
12
 
   
 
12
 
13
13
   You should have received a copy of the GNU General Public License
14
14
   along with this program; if not, write to the Free Software
15
15
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
40
40
}
41
41
 
42
42
 
43
 
int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
44
 
                 List<Item> &values, COND *conds,
 
43
int mysql_update(THD *thd,
 
44
                 TABLE_LIST *table_list,
 
45
                 List<Item> &fields,
 
46
                 List<Item> &values,
 
47
                 COND *conds,
 
48
                 ORDER *order,
45
49
                 ha_rows limit,
46
50
                 enum enum_duplicates handle_duplicates,
47
51
                 thr_lock_type lock_type)
163
167
      table->key_read=1;
164
168
      table->file->extra(HA_EXTRA_KEYREAD);
165
169
    }
 
170
 
 
171
    if (order)
 
172
    {
 
173
      uint         length;
 
174
      SORT_FIELD  *sortorder;
 
175
      TABLE_LIST   tables;
 
176
      List<Item>   fields;
 
177
      List<Item>   all_fields;
 
178
 
 
179
      bzero((char*) &tables,sizeof(tables));
 
180
      tables.table = table;
 
181
 
 
182
      table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
 
183
                                               MYF(MY_FAE | MY_ZEROFILL));
 
184
      if (setup_order(thd, &tables, fields, all_fields, order) ||
 
185
          !(sortorder=make_unireg_sortorder(order, &length)) ||
 
186
          (table->found_records = filesort(&table, sortorder, length,
 
187
                                           (SQL_SELECT *) 0, 0L, HA_POS_ERROR))
 
188
          == HA_POS_ERROR)
 
189
      {
 
190
        delete select;
 
191
        table->time_stamp=save_time_stamp;      // Restore timestamp pointer
 
192
        DBUG_RETURN(-1);
 
193
      }
 
194
    }
 
195
 
166
196
    init_read_record(&info,thd,table,select,0,1);
167
197
    thd->proc_info="searching";
168
198
 
180
210
      }
181
211
      else
182
212
      {
183
 
        if (!(test_flags & 512))                /* For debugging */       
 
213
        if (!(test_flags & 512))                /* For debugging */
184
214
        {
185
215
          DBUG_DUMP("record",(char*) table->record[0],table->reclength);
186
216
        }
202
232
      select->cond=0;
203
233
    }
204
234
    else
205
 
    {      
 
235
    {
206
236
      select= new SQL_SELECT;
207
237
      select->head=table;
208
238
    }
213
243
    {
214
244
      delete select;
215
245
      table->time_stamp=save_time_stamp;        // Restore timestamp pointer
216
 
      DBUG_RETURN(-1);  
 
246
      DBUG_RETURN(-1);
217
247
    }
218
248
  }
219
249