~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.cc

  • Committer: Brian Aker
  • Date: 2009-06-04 22:13:34 UTC
  • mfrom: (1046.1.10 merge)
  • Revision ID: brian@gaz-20090604221334-gugmt2z7otnjqt5u
Merge Brian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
    counting total_ha)
165
165
  */
166
166
  savepoint_alloc_size+= sizeof(SAVEPOINT);
167
 
  return(error);
 
167
  return error;
168
168
}
169
169
 
170
170
int ha_end()
179
179
  if (ha_finish_errors())
180
180
    error= 1;
181
181
 
182
 
  return(error);
 
182
  return error;
183
183
}
184
184
 
185
185
 
513
513
  trans->no_2pc|= not engine->has_2pc();
514
514
  if (session->transaction.xid_state.xid.is_null())
515
515
    session->transaction.xid_state.xid.set(session->query_id);
516
 
 
517
 
  return;
518
516
}
519
517
 
520
518
/**
550
548
      }
551
549
    }
552
550
  }
553
 
  return(error);
 
551
  return error;
554
552
}
555
553
 
556
554
/**
650
648
    if (is_real_trans && wait_if_global_read_lock(session, 0, 0))
651
649
    {
652
650
      ha_rollback_trans(session, all);
653
 
      return(1);
 
651
      return 1;
654
652
    }
655
653
 
656
654
    must_2pc= ha_check_and_coalesce_trx_read_only(session, ha_info, all);
691
689
    if (is_real_trans)
692
690
      start_waiting_global_read_lock(session);
693
691
  }
694
 
  return(error);
 
692
  return error;
695
693
}
696
694
 
697
695
/**
729
727
      session->transaction.cleanup();
730
728
    }
731
729
  }
732
 
  return(error);
 
730
  return error;
733
731
}
734
732
 
735
733
 
788
786
    push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
789
787
                 ER_WARNING_NOT_COMPLETE_ROLLBACK,
790
788
                 ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
791
 
  return(error);
 
789
  return error;
792
790
}
793
791
 
794
792
/**
809
807
    if (!error)
810
808
    {
811
809
      if (ha_commit_trans(session, 0))
812
 
        error=1;
 
810
        error= 1;
813
811
    }
814
812
    else
815
813
    {
820
818
 
821
819
    session->variables.tx_isolation=session->session_tx_isolation;
822
820
  }
823
 
  return(error);
 
821
 
 
822
  return error;
824
823
}
825
824
 
826
825
 
848
847
 
849
848
  if (protocol->sendFields(&field_list,
850
849
                           Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
851
 
    return(1);
 
850
    return 1;
852
851
 
853
852
  pthread_mutex_lock(&LOCK_xid_cache);
854
853
  while ((xs= (XID_STATE*)hash_element(&xid_cache, i++)))
864
863
      if (protocol->write())
865
864
      {
866
865
        pthread_mutex_unlock(&LOCK_xid_cache);
867
 
        return(1);
 
866
        return 1;
868
867
      }
869
868
    }
870
869
  }
871
870
 
872
871
  pthread_mutex_unlock(&LOCK_xid_cache);
873
872
  session->my_eof();
874
 
  return(0);
 
873
  return 0;
875
874
}
876
875
 
877
876
 
878
877
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv)
879
878
{
880
 
  int error=0;
 
879
  int error= 0;
881
880
  Session_TRANS *trans= &session->transaction.all;
882
881
  Ha_trx_info *ha_info, *ha_info_next;
883
882
 
895
894
                                         (void *)(sv+1))))
896
895
    { // cannot happen
897
896
      my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
898
 
      error=1;
 
897
      error= 1;
899
898
    }
900
899
    status_var_increment(session->status_var.ha_savepoint_rollback_count);
901
900
    trans->no_2pc|= not engine->has_2pc();
912
911
    if ((err= engine->rollback(session, !(0))))
913
912
    { // cannot happen
914
913
      my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
915
 
      error=1;
 
914
      error= 1;
916
915
    }
917
916
    status_var_increment(session->status_var.ha_rollback_count);
918
917
    ha_info_next= ha_info->next();
919
918
    ha_info->reset(); /* keep it conveniently zero-filled */
920
919
  }
921
920
  trans->ha_list= sv->ha_list;
922
 
  return(error);
 
921
  return error;
923
922
}
924
923
 
925
924
/**
930
929
*/
931
930
int ha_savepoint(Session *session, SAVEPOINT *sv)
932
931
{
933
 
  int error=0;
 
932
  int error= 0;
934
933
  Session_TRANS *trans= &session->transaction.all;
935
934
  Ha_trx_info *ha_info= trans->ha_list;
936
935
  for (; ha_info; ha_info= ha_info->next())
938
937
    int err;
939
938
    StorageEngine *engine= ha_info->engine();
940
939
    assert(engine);
941
 
/*    if (! engine->savepoint_set)
 
940
#ifdef NOT_IMPLEMENTED /*- TODO (examine this againt the original code base) */
 
941
    if (! engine->savepoint_set)
942
942
    {
943
943
      my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "SAVEPOINT");
944
 
      error=1;
 
944
      error= 1;
945
945
      break;
946
 
    } */
 
946
    } 
 
947
#endif
947
948
    if ((err= engine->savepoint_set(session, (void *)(sv+1))))
948
949
    { // cannot happen
949
950
      my_error(ER_GET_ERRNO, MYF(0), err);
950
 
      error=1;
 
951
      error= 1;
951
952
    }
952
953
    status_var_increment(session->status_var.ha_savepoint_count);
953
954
  }
956
957
    engines are prepended to the beginning of the list.
957
958
  */
958
959
  sv->ha_list= trans->ha_list;
959
 
  return(error);
 
960
  return error;
960
961
}
961
962
 
962
963
int ha_release_savepoint(Session *session, SAVEPOINT *sv)
963
964
{
964
 
  int error=0;
 
965
  int error= 0;
965
966
  Ha_trx_info *ha_info= sv->ha_list;
966
967
 
967
968
  for (; ha_info; ha_info= ha_info->next())
974
975
                                        (void *)(sv+1))))
975
976
    { // cannot happen
976
977
      my_error(ER_GET_ERRNO, MYF(0), err);
977
 
      error=1;
 
978
      error= 1;
978
979
    }
979
980
  }
980
 
  return(error);
 
981
  return error;
981
982
}
982
983
 
983
984
 
1015
1016
int handler::ha_index_init(uint32_t idx, bool sorted)
1016
1017
{
1017
1018
  int result;
1018
 
  assert(inited==NONE);
 
1019
  assert(inited == NONE);
1019
1020
  if (!(result= index_init(idx, sorted)))
1020
1021
    inited=INDEX;
1021
1022
  end_range= NULL;
1022
 
  return(result);
 
1023
  return result;
1023
1024
}
1024
1025
 
1025
1026
int handler::ha_index_end()
1035
1036
  int result;
1036
1037
  assert(inited==NONE || (inited==RND && scan));
1037
1038
  inited= (result= rnd_init(scan)) ? NONE: RND;
1038
 
  return(result);
 
1039
 
 
1040
  return result;
1039
1041
}
1040
1042
 
1041
1043
int handler::ha_rnd_end()
1158
1160
      dup_ref=ref+ALIGN_SIZE(ref_length);
1159
1161
    cached_table_flags= table_flags();
1160
1162
  }
1161
 
  return(error);
 
1163
  return error;
1162
1164
}
1163
1165
 
1164
1166
/**
1174
1176
 
1175
1177
  position(record);
1176
1178
  if (inited && (error= ha_index_end()))
1177
 
    return(error);
 
1179
    return error;
1178
1180
  if ((error= ha_rnd_init(false)))
1179
 
    return(error);
 
1181
    return error;
1180
1182
 
1181
 
  return(rnd_pos(record, ref));
 
1183
  return rnd_pos(record, ref);
1182
1184
}
1183
1185
 
1184
1186
/**
1212
1214
    error=index_first(buf);
1213
1215
    (void) ha_index_end();
1214
1216
  }
1215
 
  return(error);
 
1217
  return error;
1216
1218
}
1217
1219
 
1218
1220
/**
1389
1391
    */
1390
1392
    adjust_next_insert_id_after_explicit_value(nr);
1391
1393
    insert_id_for_cur_row= 0; // didn't generate anything
1392
 
    return(0);
 
1394
 
 
1395
    return 0;
1393
1396
  }
1394
1397
 
1395
1398
  if ((nr= next_insert_id) >= auto_inc_interval_for_cur_row.maximum())
1443
1446
                         nb_desired_values, &nr,
1444
1447
                         &nb_reserved_values);
1445
1448
      if (nr == ~(uint64_t) 0)
1446
 
        return(HA_ERR_AUTOINC_READ_FAILED);  // Mark failure
 
1449
        return HA_ERR_AUTOINC_READ_FAILED;  // Mark failure
1447
1450
 
1448
1451
      /*
1449
1452
        That rounding below should not be needed when all engines actually
1469
1472
      first test if the query was aborted due to strict mode constraints
1470
1473
    */
1471
1474
    if (session->killed == Session::KILL_BAD_DATA)
1472
 
      return(HA_ERR_AUTOINC_ERANGE);
 
1475
      return HA_ERR_AUTOINC_ERANGE;
1473
1476
 
1474
1477
    /*
1475
1478
      field refused this value (overflow) and truncated it, use the result of
1503
1506
  */
1504
1507
  set_next_insert_id(compute_next_insert_id(nr, variables));
1505
1508
 
1506
 
  return(0);
 
1509
  return 0;
1507
1510
}
1508
1511
 
1509
1512
 
1809
1812
    }
1810
1813
  }
1811
1814
  my_error(textno, errflag, table_share->table_name.str, error);
1812
 
  return;
1813
1815
}
1814
1816
 
1815
1817
 
1822
1824
  @return
1823
1825
    Returns true if this is a temporary error
1824
1826
*/
1825
 
bool handler::get_error_message(int ,
1826
 
                                String* )
 
1827
bool handler::get_error_message(int , String* )
1827
1828
{
1828
1829
  return false;
1829
1830
}
2200
2201
*/
2201
2202
int ha_enable_transaction(Session *session, bool on)
2202
2203
{
2203
 
  int error=0;
 
2204
  int error= 0;
2204
2205
 
2205
2206
  if ((session->transaction.on= on))
2206
2207
  {
2215
2216
        error= 1;
2216
2217
 
2217
2218
  }
2218
 
  return(error);
 
2219
  return error;
2219
2220
}
2220
2221
 
2221
2222
int handler::index_next_same(unsigned char *buf, const unsigned char *key, uint32_t keylen)
2265
2266
        key_part->field->move_field_offset(-ptrdiff);
2266
2267
    }
2267
2268
  }
2268
 
  return(error);
 
2269
  return error;
2269
2270
}
2270
2271
 
2271
2272
 
2310
2311
                                tmp_buff_size,
2311
2312
                                division_limit, age_threshold));
2312
2313
  }
2313
 
  return(0);
 
2314
  return 0;
2314
2315
}
2315
2316
 
2316
2317
 
2331
2332
                                  tmp_buff_size,
2332
2333
                                  division_limit, age_threshold));
2333
2334
  }
2334
 
  return(0);
 
2335
  return 0;
2335
2336
}
2336
2337
 
2337
2338
 
2597
2598
  mrr_funcs= *seq_funcs;
2598
2599
  mrr_is_output_sorted= test(mode & HA_MRR_SORTED);
2599
2600
  mrr_have_range= false;
2600
 
  return(0);
 
2601
  return 0;
2601
2602
}
2602
2603
 
2603
2604
 
2664
2665
  while ((result == HA_ERR_END_OF_FILE) && !range_res);
2665
2666
 
2666
2667
  *range_info= mrr_cur_range.ptr;
2667
 
  return(result);
 
2668
  return result;
2668
2669
}
2669
2670
 
2670
2671
 
2725
2726
      new_h2->ha_external_lock(session, F_RDLCK))
2726
2727
  {
2727
2728
    delete new_h2;
2728
 
    return(1);
 
2729
    return 1;
2729
2730
  }
2730
2731
 
2731
2732
  if (keyno == h_in->pushed_idx_cond_keyno)
2761
2762
  if (h_in->ha_rnd_init(false))
2762
2763
    goto error;
2763
2764
 
2764
 
  return(0);
 
2765
  return 0;
2765
2766
error:
2766
2767
  h2->ha_index_or_rnd_end();
2767
2768
  h2->ha_external_lock(session, F_UNLCK);
2768
2769
  h2->close();
2769
2770
  delete h2;
2770
 
  return(1);
 
2771
  return 1;
2771
2772
}
2772
2773
 
2773
2774
 
2781
2782
    h2= NULL;
2782
2783
  }
2783
2784
  use_default_impl= true;
2784
 
  return;
2785
2785
}
2786
2786
 
2787
2787
 
2830
2830
  }
2831
2831
 
2832
2832
  if (res && res != HA_ERR_END_OF_FILE)
2833
 
    return(res);
 
2833
    return res;
2834
2834
  dsmrr_eof= test(res == HA_ERR_END_OF_FILE);
2835
2835
 
2836
2836
  /* Sort the buffer contents by rowid */
2841
2841
            (void*)h);
2842
2842
  rowids_buf_last= rowids_buf_cur;
2843
2843
  rowids_buf_cur=  rowids_buf;
2844
 
  return(0);
 
2844
  return 0;
2845
2845
}
2846
2846
 
2847
2847
 
3234
3234
                          DISK_SEEK_PROP_COST*n_blocks/busy_blocks);
3235
3235
    }
3236
3236
  }
3237
 
  return;
3238
3237
}
3239
3238
 
3240
3239
 
3320
3319
  }
3321
3320
  result= index_next(table->record[0]);
3322
3321
  if (result)
3323
 
    return(result);
 
3322
    return result;
3324
3323
  return(compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
3325
3324
}
3326
3325
 
3486
3485
  int error= external_lock(session, lock_type);
3487
3486
  if (error == 0)
3488
3487
    cached_table_flags= table_flags();
3489
 
  return(error);
 
3488
  return error;
3490
3489
}
3491
3490
 
3492
3491
 
3528
3527
  mark_trx_read_write();
3529
3528
 
3530
3529
  if (unlikely(error= write_row(buf)))
3531
 
    return(error);
 
3530
    return error;
3532
3531
 
3533
3532
  if (unlikely(log_row_for_replication(table, 0, buf)))
3534
3533
    return HA_ERR_RBR_LOGGING_FAILED; /* purecov: inspected */
3535
3534
 
3536
3535
  DRIZZLE_INSERT_ROW_END();
3537
 
  return(0);
 
3536
  return 0;
3538
3537
}
3539
3538
 
3540
3539