~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Brian Aker
  • Date: 2011-01-26 02:13:21 UTC
  • mto: (2122.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2118.
  • Revision ID: brian@tangent.org-20110126021321-3vxltp6aianxs18a
Additional abstract around time (this also makes the abort_on_warnings in
session private).

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
      table->cursor->ha_release_auto_increment();
282
282
    if (!joins_freed)
283
283
      free_underlaid_joins(session, &session->lex->select_lex);
284
 
    session->abort_on_warning= 0;
 
284
    session->setAbortOnWarning(false);
285
285
    DRIZZLE_INSERT_DONE(1, 0);
286
286
    return true;
287
287
  }
320
320
        table->cursor->ha_release_auto_increment();
321
321
      if (!joins_freed)
322
322
        free_underlaid_joins(session, &session->lex->select_lex);
323
 
      session->abort_on_warning= 0;
 
323
      session->setAbortOnWarning(false);
324
324
      DRIZZLE_INSERT_DONE(1, 0);
325
325
 
326
326
      return true;
331
331
        table->cursor->ha_release_auto_increment();
332
332
      if (!joins_freed)
333
333
        free_underlaid_joins(session, &session->lex->select_lex);
334
 
      session->abort_on_warning= 0;
 
334
      session->setAbortOnWarning(false);
335
335
      DRIZZLE_INSERT_DONE(1, 0);
336
336
      return true;
337
337
    }
372
372
  }
373
373
 
374
374
 
375
 
  session->abort_on_warning= !ignore;
 
375
  session->setAbortOnWarning(not ignore);
376
376
 
377
377
  table->mark_columns_needed_for_insert();
378
378
 
483
483
      table->cursor->ha_release_auto_increment();
484
484
    if (!joins_freed)
485
485
      free_underlaid_joins(session, &session->lex->select_lex);
486
 
    session->abort_on_warning= 0;
 
486
    session->setAbortOnWarning(false);
487
487
    DRIZZLE_INSERT_DONE(1, 0);
488
488
    return true;
489
489
  }
509
509
                   info.copied + info.deleted + info.touched, id, buff);
510
510
  }
511
511
  session->status_var.inserted_row_count+= session->row_count_func;
512
 
  session->abort_on_warning= 0;
 
512
  session->setAbortOnWarning(false);
513
513
  DRIZZLE_INSERT_DONE(0, session->row_count_func);
514
514
 
515
515
  return false;
610
610
    inserting (for INSERT ... SELECT this is done by changing table_list,
611
611
    because INSERT ... SELECT share Select_Lex it with SELECT.
612
612
  */
613
 
  if (!select_insert)
 
613
  if (not select_insert)
614
614
  {
615
615
    for (Select_Lex_Unit *un= select_lex->first_inner_unit();
616
616
         un;
658
658
 
659
659
    if (!res && check_fields)
660
660
    {
661
 
      bool saved_abort_on_warning= session->abort_on_warning;
662
 
      session->abort_on_warning= abort_on_warning;
 
661
      bool saved_abort_on_warning= session->abortOnWarning();
 
662
 
 
663
      session->setAbortOnWarning(abort_on_warning);
663
664
      res= check_that_all_fields_are_given_values(session,
664
665
                                                  table ? table :
665
666
                                                  context->table_list->table,
666
667
                                                  context->table_list);
667
 
      session->abort_on_warning= saved_abort_on_warning;
 
668
      session->setAbortOnWarning(saved_abort_on_warning);
668
669
    }
669
670
 
670
671
    if (!res && duplic == DUP_UPDATE)
675
676
    /* Restore the current context. */
676
677
    ctx_state.restore_state(context, table_list);
677
678
 
678
 
    if (!res)
 
679
    if (not res)
679
680
      res= setup_fields(session, 0, update_values, MARK_COLUMNS_READ, 0, 0);
680
681
  }
681
682
 
682
683
  if (res)
683
684
    return(res);
684
685
 
685
 
  if (!table)
 
686
  if (not table)
686
687
    table= table_list->table;
687
688
 
688
 
  if (!select_insert)
 
689
  if (not select_insert)
689
690
  {
690
691
    TableList *duplicate;
691
692
    if ((duplicate= unique_table(table_list, table_list->next_global, true)))
695
696
      return true;
696
697
    }
697
698
  }
 
699
 
698
700
  if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
699
701
    table->prepare_for_position();
700
702
 
1014
1016
      }
1015
1017
    }
1016
1018
  }
1017
 
  return session->abort_on_warning ? err : 0;
 
1019
  return session->abortOnWarning() ? err : 0;
1018
1020
}
1019
1021
 
1020
1022
/***************************************************************************
1103
1105
 
1104
1106
  if (!res && fields->elements)
1105
1107
  {
1106
 
    bool saved_abort_on_warning= session->abort_on_warning;
1107
 
    session->abort_on_warning= !info.ignore;
 
1108
    bool saved_abort_on_warning= session->abortOnWarning();
 
1109
    session->setAbortOnWarning(not info.ignore);
1108
1110
    res= check_that_all_fields_are_given_values(session, table_list->table,
1109
1111
                                                table_list);
1110
 
    session->abort_on_warning= saved_abort_on_warning;
 
1112
    session->setAbortOnWarning(saved_abort_on_warning);
1111
1113
  }
1112
1114
 
1113
1115
  if (info.handle_duplicates == DUP_UPDATE && !res)
1200
1202
  table->next_number_field=table->found_next_number_field;
1201
1203
 
1202
1204
  session->cuted_fields=0;
 
1205
 
1203
1206
  if (info.ignore || info.handle_duplicates != DUP_ERROR)
1204
1207
    table->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
 
1208
 
1205
1209
  if (info.handle_duplicates == DUP_REPLACE)
1206
1210
    table->cursor->extra(HA_EXTRA_WRITE_CAN_REPLACE);
 
1211
 
1207
1212
  if (info.handle_duplicates == DUP_UPDATE)
1208
1213
    table->cursor->extra(HA_EXTRA_INSERT_WITH_UPDATE);
1209
 
  session->abort_on_warning= !info.ignore;
 
1214
 
 
1215
  session->setAbortOnWarning(not info.ignore);
1210
1216
  table->mark_columns_needed_for_insert();
1211
1217
 
1212
1218
 
1255
1261
    table->cursor->ha_reset();
1256
1262
  }
1257
1263
  session->count_cuted_fields= CHECK_FIELD_IGNORE;
1258
 
  session->abort_on_warning= 0;
 
1264
  session->setAbortOnWarning(false);
1259
1265
  return;
1260
1266
}
1261
1267
 
1268
1274
  if (unit->offset_limit_cnt)
1269
1275
  {                                             // using limit offset,count
1270
1276
    unit->offset_limit_cnt--;
1271
 
    return(0);
 
1277
    return false;
1272
1278
  }
1273
1279
 
1274
1280
  session->count_cuted_fields= CHECK_FIELD_WARN;        // Calculate cuted fields
1275
1281
  store_values(values);
1276
1282
  session->count_cuted_fields= CHECK_FIELD_IGNORE;
1277
1283
  if (session->is_error())
1278
 
    return(1);
 
1284
    return true;
1279
1285
 
1280
1286
  // Release latches in case bulk insert takes a long time
1281
1287
  plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
1711
1717
  session->cuted_fields=0;
1712
1718
  if (info.ignore || info.handle_duplicates != DUP_ERROR)
1713
1719
    table->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
 
1720
 
1714
1721
  if (info.handle_duplicates == DUP_REPLACE)
1715
1722
    table->cursor->extra(HA_EXTRA_WRITE_CAN_REPLACE);
 
1723
 
1716
1724
  if (info.handle_duplicates == DUP_UPDATE)
1717
1725
    table->cursor->extra(HA_EXTRA_INSERT_WITH_UPDATE);
 
1726
 
1718
1727
  table->cursor->ha_start_bulk_insert((ha_rows) 0);
1719
 
  session->abort_on_warning= !info.ignore;
 
1728
  session->setAbortOnWarning(not info.ignore);
1720
1729
  if (check_that_all_fields_are_given_values(session, table, table_list))
1721
1730
    return(1);
 
1731
 
1722
1732
  table->mark_columns_needed_for_insert();
1723
1733
  table->cursor->extra(HA_EXTRA_WRITE_CACHE);
1724
1734
  return(0);