~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

A number of dead code removal patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4254
4254
 
4255
4255
  SYNOPSIS
4256
4256
  fill_record()
4257
 
  session           thread Cursor
4258
4257
  fields        Item_fields list to be filled
4259
4258
  values        values to fill with
4260
4259
  ignore_errors true if we should ignore errors
4270
4269
*/
4271
4270
 
4272
4271
bool
4273
 
fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors)
 
4272
fill_record(Session *session, List<Item> &fields, List<Item> &values, bool ignore_errors)
4274
4273
{
4275
4274
  List_iterator_fast<Item> f(fields),v(values);
4276
 
  Item *value, *fld;
 
4275
  Item *value;
4277
4276
  Item_field *field;
4278
 
  Table *table= 0;
4279
 
  List<Table> tbl_list;
4280
 
  bool abort_on_warning_saved= session->abort_on_warning;
4281
 
  tbl_list.empty();
 
4277
  Table *table;
4282
4278
 
4283
4279
  /*
4284
4280
    Reset the table->auto_increment_field_not_null as it is valid for
4290
4286
      On INSERT or UPDATE fields are checked to be from the same table,
4291
4287
      thus we safely can take table from the first field.
4292
4288
    */
4293
 
    fld= (Item_field*)f++;
4294
 
    if (!(field= fld->filed_for_view_update()))
4295
 
    {
4296
 
      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
4297
 
      goto err;
4298
 
    }
 
4289
    field= static_cast<Item_field *>(f++);
4299
4290
    table= field->field->table;
4300
4291
    table->auto_increment_field_not_null= false;
4301
4292
    f.rewind();
4302
4293
  }
4303
 
  while ((fld= f++))
 
4294
 
 
4295
  while ((field= static_cast<Item_field *>(f++)))
4304
4296
  {
4305
 
    if (!(field= fld->filed_for_view_update()))
4306
 
    {
4307
 
      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
4308
 
      goto err;
4309
 
    }
4310
 
    value=v++;
 
4297
    value= v++;
 
4298
 
4311
4299
    Field *rfield= field->field;
4312
4300
    table= rfield->table;
 
4301
 
4313
4302
    if (rfield == table->next_number_field)
4314
4303
      table->auto_increment_field_not_null= true;
4315
4304
    if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
4317
4306
      my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
4318
4307
      goto err;
4319
4308
    }
4320
 
    tbl_list.push_back(table);
4321
 
  }
4322
 
  /* Update virtual fields*/
4323
 
  session->abort_on_warning= false;
4324
 
  if (tbl_list.head())
4325
 
  {
4326
 
    List_iterator_fast<Table> t(tbl_list);
4327
 
    Table *prev_table= 0;
4328
 
    while ((table= t++))
4329
 
    {
4330
 
      /*
4331
 
        Do simple optimization to prevent unnecessary re-generating
4332
 
        values for virtual fields
4333
 
      */
4334
 
      if (table != prev_table)
4335
 
        prev_table= table;
4336
 
    }
4337
 
  }
4338
 
  session->abort_on_warning= abort_on_warning_saved;
4339
 
  return(session->is_error());
 
4309
  }
 
4310
 
 
4311
  return session->is_error();
 
4312
 
4340
4313
err:
4341
 
  session->abort_on_warning= abort_on_warning_saved;
4342
4314
  if (table)
4343
4315
    table->auto_increment_field_not_null= false;
 
4316
 
4344
4317
  return true;
4345
4318
}
4346
4319
 
4350
4323
 
4351
4324
  SYNOPSIS
4352
4325
  fill_record()
4353
 
  session           thread Cursor
4354
4326
  ptr           pointer on pointer to record
4355
4327
  values        list of fields
4356
4328
  ignore_errors true if we should ignore errors
4365
4337
  true    error occured
4366
4338
*/
4367
4339
 
4368
 
bool
4369
 
fill_record(Session *session, Field **ptr, List<Item> &values,
4370
 
            bool )
 
4340
bool fill_record(Session *session, Field **ptr, List<Item> &values, bool)
4371
4341
{
4372
4342
  List_iterator_fast<Item> v(values);
4373
4343
  Item *value;
4374
4344
  Table *table= 0;
4375
4345
  Field *field;
4376
 
  List<Table> tbl_list;
4377
 
  bool abort_on_warning_saved= session->abort_on_warning;
4378
4346
 
4379
 
  tbl_list.empty();
4380
4347
  /*
4381
4348
    Reset the table->auto_increment_field_not_null as it is valid for
4382
4349
    only one row.
4398
4365
      table->auto_increment_field_not_null= true;
4399
4366
    if (value->save_in_field(field, 0) < 0)
4400
4367
      goto err;
4401
 
    tbl_list.push_back(table);
4402
 
  }
4403
 
  /* Update virtual fields*/
4404
 
  session->abort_on_warning= false;
4405
 
  if (tbl_list.head())
4406
 
  {
4407
 
    List_iterator_fast<Table> t(tbl_list);
4408
 
    Table *prev_table= 0;
4409
 
    while ((table= t++))
4410
 
    {
4411
 
      /*
4412
 
        Do simple optimization to prevent unnecessary re-generating
4413
 
        values for virtual fields
4414
 
      */
4415
 
      if (table != prev_table)
4416
 
      {
4417
 
        prev_table= table;
4418
 
      }
4419
 
    }
4420
 
  }
4421
 
  session->abort_on_warning= abort_on_warning_saved;
 
4368
  }
 
4369
 
4422
4370
  return(session->is_error());
4423
4371
 
4424
4372
err:
4425
 
  session->abort_on_warning= abort_on_warning_saved;
4426
4373
  if (table)
4427
4374
    table->auto_increment_field_not_null= false;
 
4375
 
4428
4376
  return true;
4429
4377
}
4430
4378