~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/handler.cc

  • Committer: Monty Taylor
  • Date: 2008-07-05 11:38:34 UTC
  • mfrom: (60 drizzle)
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: monty@inaugust.com-20080705113834-23bn0884hk8pqfu9
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
495
495
  handlerton *hton= plugin_data(plugin, handlerton *);
496
496
  if (hton->state == SHOW_OPTION_YES && hton->drop_database)
497
497
    hton->drop_database(hton, (char *)path);
498
 
  return FALSE;
 
498
  return false;
499
499
}
500
500
 
501
501
 
516
516
  if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
517
517
      thd_get_ha_data(thd, hton))
518
518
    hton->close_connection(hton, thd);
519
 
  return FALSE;
 
519
  return false;
520
520
}
521
521
 
522
522
 
911
911
  As a side effect, propagates the read-only/read-write flags
912
912
  of the statement transaction to its enclosing normal transaction.
913
913
 
914
 
  @retval TRUE   we must run a two-phase commit. Returned
 
914
  @retval true   we must run a two-phase commit. Returned
915
915
                 if we have at least two engines with read-write changes.
916
 
  @retval FALSE  Don't need two-phase commit. Even if we have two
 
916
  @retval false  Don't need two-phase commit. Even if we have two
917
917
                 transactional engines, we can run two independent
918
918
                 commits if changes in one of the engines are read-only.
919
919
*/
943
943
        that ha_info_all is registered in thd->transaction.all.
944
944
        Since otherwise we only clutter the normal transaction flags.
945
945
      */
946
 
      if (ha_info_all->is_started()) /* FALSE if autocommit. */
 
946
      if (ha_info_all->is_started()) /* false if autocommit. */
947
947
        ha_info_all->coalesce_trx_with(ha_info);
948
948
    }
949
949
    else if (rw_ha_count > 1)
1179
1179
    }
1180
1180
  }
1181
1181
  if (all)
1182
 
    thd->transaction_rollback_request= FALSE;
 
1182
    thd->transaction_rollback_request= false;
1183
1183
 
1184
1184
  /*
1185
1185
    If a non-transactional table was updated, warn; don't warn if this is a
1246
1246
    hton->commit_by_xid(hton, ((struct xahton_st *)arg)->xid);
1247
1247
    ((struct xahton_st *)arg)->result= 0;
1248
1248
  }
1249
 
  return FALSE;
 
1249
  return false;
1250
1250
}
1251
1251
 
1252
1252
static my_bool xarollback_handlerton(THD *unused1, plugin_ref plugin,
1258
1258
    hton->rollback_by_xid(hton, ((struct xahton_st *)arg)->xid);
1259
1259
    ((struct xahton_st *)arg)->result= 0;
1260
1260
  }
1261
 
  return FALSE;
 
1261
  return false;
1262
1262
}
1263
1263
 
1264
1264
 
1289
1289
  {
1290
1290
    uchar c=(uchar)xid->data[i];
1291
1291
    /* is_next_dig is set if next character is a number */
1292
 
    bool is_next_dig= FALSE;
 
1292
    bool is_next_dig= false;
1293
1293
    if (i < XIDDATASIZE)
1294
1294
    {
1295
1295
      char ch= xid->data[i+1];
1411
1411
        break;
1412
1412
    }
1413
1413
  }
1414
 
  return FALSE;
 
1414
  return false;
1415
1415
}
1416
1416
 
1417
1417
int ha_recover(HASH *commit_list)
1444
1444
 
1445
1445
  DBUG_ASSERT(total_ha_2pc == (ulong) opt_bin_log+1); // only InnoDB and binlog
1446
1446
  tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK
1447
 
  info.dry_run=FALSE;
 
1447
  info.dry_run=false;
1448
1448
#endif
1449
1449
 
1450
1450
 
1513
1513
    if (xs->xa_state==XA_PREPARED)
1514
1514
    {
1515
1515
      protocol->prepare_for_resend();
1516
 
      protocol->store_longlong((longlong)xs->xid.formatID, FALSE);
1517
 
      protocol->store_longlong((longlong)xs->xid.gtrid_length, FALSE);
1518
 
      protocol->store_longlong((longlong)xs->xid.bqual_length, FALSE);
 
1516
      protocol->store_longlong((longlong)xs->xid.formatID, false);
 
1517
      protocol->store_longlong((longlong)xs->xid.gtrid_length, false);
 
1518
      protocol->store_longlong((longlong)xs->xid.bqual_length, false);
1519
1519
      protocol->store(xs->xid.data, xs->xid.gtrid_length+xs->xid.bqual_length,
1520
1520
                      &my_charset_bin);
1521
1521
      if (protocol->write())
1557
1557
  if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
1558
1558
    hton->release_temporary_latches(hton, thd);
1559
1559
 
1560
 
  return FALSE;
 
1560
  return false;
1561
1561
}
1562
1562
 
1563
1563
 
1694
1694
    hton->start_consistent_snapshot(hton, thd);
1695
1695
    *((bool *)arg)= false;
1696
1696
  }
1697
 
  return FALSE;
 
1697
  return false;
1698
1698
}
1699
1699
 
1700
1700
int ha_start_consistent_snapshot(THD *thd)
1721
1721
  handlerton *hton= plugin_data(plugin, handlerton *);
1722
1722
  if (hton->state == SHOW_OPTION_YES && hton->flush_logs && 
1723
1723
      hton->flush_logs(hton))
1724
 
    return TRUE;
1725
 
  return FALSE;
 
1724
    return true;
 
1725
  return false;
1726
1726
}
1727
1727
 
1728
1728
 
1732
1732
  {
1733
1733
    if (plugin_foreach(NULL, flush_handlerton,
1734
1734
                          MYSQL_STORAGE_ENGINE_PLUGIN, 0))
1735
 
      return TRUE;
 
1735
      return true;
1736
1736
  }
1737
1737
  else
1738
1738
  {
1739
1739
    if (db_type->state != SHOW_OPTION_YES ||
1740
1740
        (db_type->flush_logs && db_type->flush_logs(db_type)))
1741
 
      return TRUE;
 
1741
      return true;
1742
1742
  }
1743
 
  return FALSE;
 
1743
  return false;
1744
1744
}
1745
1745
 
1746
1746
static const char *check_lowercase_names(handler *file, const char *path,
1788
1788
{
1789
1789
  /* Grab the error message */
1790
1790
  strmake(buff, message, sizeof(buff)-1);
1791
 
  return TRUE;
 
1791
  return true;
1792
1792
}
1793
1793
 
1794
1794
 
1973
1973
  position(record);
1974
1974
  if (inited && (error= ha_index_end()))
1975
1975
    DBUG_RETURN(error);
1976
 
  if ((error= ha_rnd_init(FALSE)))
 
1976
  if ((error= ha_rnd_init(false)))
1977
1977
    DBUG_RETURN(error);
1978
1978
 
1979
1979
  DBUG_RETURN(rnd_pos(record, ref));
2166
2166
int handler::update_auto_increment()
2167
2167
{
2168
2168
  uint64_t nr, nb_reserved_values;
2169
 
  bool append= FALSE;
 
2169
  bool append= false;
2170
2170
  THD *thd= table->in_use;
2171
2171
  struct system_variables *variables= &thd->variables;
2172
2172
  DBUG_ENTER("handler::update_auto_increment");
2258
2258
    if (table->s->next_number_keypart == 0)
2259
2259
    {
2260
2260
      /* We must defer the appending until "nr" has been possibly truncated */
2261
 
      append= TRUE;
 
2261
      append= true;
2262
2262
    }
2263
2263
    else
2264
2264
    {
2274
2274
 
2275
2275
  DBUG_PRINT("info",("auto_increment: %lu", (ulong) nr));
2276
2276
 
2277
 
  if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
 
2277
  if (unlikely(table->next_number_field->store((longlong) nr, true)))
2278
2278
  {
2279
2279
    /*
2280
2280
      first test if the query was aborted due to strict mode constraints
2291
2291
      interval will cause a duplicate key).
2292
2292
    */
2293
2293
    nr= prev_insert_id(table->next_number_field->val_int(), variables);
2294
 
    if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
 
2294
    if (unlikely(table->next_number_field->store((longlong) nr, true)))
2295
2295
      nr= table->next_number_field->val_int();
2296
2296
  }
2297
2297
  if (append)
2631
2631
    {
2632
2632
      /* The error was "unknown" to this function.
2633
2633
         Ask handler if it has got a message for this error */
2634
 
      bool temporary= FALSE;
 
2634
      bool temporary= false;
2635
2635
      String str;
2636
2636
      temporary= get_error_message(error, &str);
2637
2637
      if (!str.is_empty())
2663
2663
*/
2664
2664
bool handler::get_error_message(int error, String* buf)
2665
2665
{
2666
 
  return FALSE;
 
2666
  return false;
2667
2667
}
2668
2668
 
2669
2669
 
3464
3464
      (!(hton->discover(hton, thd, vargs->db, vargs->name, 
3465
3465
                        vargs->frmblob, 
3466
3466
                        vargs->frmlen))))
3467
 
    return TRUE;
 
3467
    return true;
3468
3468
 
3469
 
  return FALSE;
 
3469
  return false;
3470
3470
}
3471
3471
 
3472
3472
int ha_discover(THD *thd, const char *db, const char *name,
3533
3533
 
3534
3534
  vargs->err = err;
3535
3535
  if (vargs->err == HA_ERR_TABLE_EXIST)
3536
 
    return TRUE;
 
3536
    return true;
3537
3537
 
3538
 
  return FALSE;
 
3538
  return false;
3539
3539
}
3540
3540
 
3541
3541
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name)
3775
3775
  mrr_iter= seq_funcs->init(seq_init_param, n_ranges, mode);
3776
3776
  mrr_funcs= *seq_funcs;
3777
3777
  mrr_is_output_sorted= test(mode & HA_MRR_SORTED);
3778
 
  mrr_have_range= FALSE;
 
3778
  mrr_have_range= false;
3779
3779
  DBUG_RETURN(0);
3780
3780
}
3781
3781
 
3801
3801
 
3802
3802
  if (!mrr_have_range)
3803
3803
  {
3804
 
    mrr_have_range= TRUE;
 
3804
    mrr_have_range= true;
3805
3805
    goto start;
3806
3806
  }
3807
3807
 
3884
3884
  DBUG_ASSERT(h2 == NULL);
3885
3885
  if (mode & HA_MRR_USE_DEFAULT_IMPL || mode & HA_MRR_SORTED)
3886
3886
  {
3887
 
    use_default_impl= TRUE;
 
3887
    use_default_impl= true;
3888
3888
    DBUG_RETURN(h->handler::multi_range_read_init(seq_funcs, seq_init_param,
3889
3889
                                                  n_ranges, mode, buf));
3890
3890
  }
3922
3922
  table->prepare_for_position();
3923
3923
  new_h2->extra(HA_EXTRA_KEYREAD);
3924
3924
 
3925
 
  if (h2->ha_index_init(keyno, FALSE) || 
 
3925
  if (h2->ha_index_init(keyno, false) || 
3926
3926
      h2->handler::multi_range_read_init(seq_funcs, seq_init_param, n_ranges,
3927
3927
                                         mode, buf))
3928
3928
    goto error;
3929
 
  use_default_impl= FALSE;
 
3929
  use_default_impl= false;
3930
3930
  
3931
3931
  if (pushed_cond)
3932
3932
    h2->idx_cond_push(keyno, pushed_cond);
3940
3940
  if (dsmrr_eof) 
3941
3941
    buf->end_of_used_area= rowids_buf_last;
3942
3942
 
3943
 
  if (h->ha_rnd_init(FALSE))
 
3943
  if (h->ha_rnd_init(false))
3944
3944
    goto error;
3945
3945
  
3946
3946
  DBUG_RETURN(0);
3963
3963
    delete h2;
3964
3964
    h2= NULL;
3965
3965
  }
3966
 
  use_default_impl= TRUE;
 
3966
  use_default_impl= true;
3967
3967
  DBUG_VOID_RETURN;
3968
3968
}
3969
3969
 
4161
4161
    Allow use of DS-MRR in cases where the index has partially-covered
4162
4162
    components but they are not used for scanning.
4163
4163
 
4164
 
  @retval TRUE   Yes
4165
 
  @retval FALSE  No
 
4164
  @retval true   Yes
 
4165
  @retval false  No
4166
4166
*/
4167
4167
 
4168
4168
bool DsMrr_impl::key_uses_partial_cols(uint keyno)
4172
4172
  for (; kp != kp_end; kp++)
4173
4173
  {
4174
4174
    if (!kp->field->part_of_key.is_set(keyno))
4175
 
      return TRUE;
 
4175
      return true;
4176
4176
  }
4177
 
  return FALSE;
 
4177
  return false;
4178
4178
}
4179
4179
 
4180
4180
 
4197
4197
                OUT  If DS-MRR is choosen, cost of DS-MRR scan
4198
4198
                     else the value is not modified
4199
4199
 
4200
 
  @retval TRUE   Default MRR implementation should be used
4201
 
  @retval FALSE  DS-MRR implementation should be used
 
4200
  @retval true   Default MRR implementation should be used
 
4201
  @retval false  DS-MRR implementation should be used
4202
4202
*/
4203
4203
 
4204
4204
bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
4215
4215
  {
4216
4216
    /* Use the default implementation */
4217
4217
    *flags |= HA_MRR_USE_DEFAULT_IMPL;
4218
 
    return TRUE;
 
4218
    return true;
4219
4219
  }
4220
4220
  
4221
4221
  uint add_len= table->key_info[keyno].key_length + h->ref_length; 
4222
4222
  *bufsz -= add_len;
4223
4223
  if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, &dsmrr_cost))
4224
 
    return TRUE;
 
4224
    return true;
4225
4225
  *bufsz += add_len;
4226
4226
  
4227
4227
  bool force_dsmrr;
4240
4240
    *flags &= ~HA_MRR_USE_DEFAULT_IMPL;  /* Use the DS-MRR implementation */
4241
4241
    *flags &= ~HA_MRR_SORTED;          /* We will return unordered output */
4242
4242
    *cost= dsmrr_cost;
4243
 
    res= FALSE;
 
4243
    res= false;
4244
4244
  }
4245
4245
  else
4246
4246
  {
4247
4247
    /* Use the default MRR implementation */
4248
 
    res= TRUE;
 
4248
    res= true;
4249
4249
  }
4250
4250
  return res;
4251
4251
}
4263
4263
  @param buffer_size INOUT  Buffer size
4264
4264
  @param cost        OUT    The cost
4265
4265
 
4266
 
  @retval FALSE  OK
4267
 
  @retval TRUE   Error, DS-MRR cannot be used (the buffer is too small
 
4266
  @retval false  OK
 
4267
  @retval true   Error, DS-MRR cannot be used (the buffer is too small
4268
4268
                 for even 1 rowid)
4269
4269
*/
4270
4270
 
4280
4280
  max_buff_entries = *buffer_size / elem_size;
4281
4281
 
4282
4282
  if (!max_buff_entries)
4283
 
    return TRUE; /* Buffer has not enough space for even 1 rowid */
 
4283
    return true; /* Buffer has not enough space for even 1 rowid */
4284
4284
 
4285
4285
  /* Number of iterations we'll make with full buffer */
4286
4286
  n_full_steps= (uint)floor(rows2double(rows) / max_buff_entries);
4319
4319
  /* Total cost of all index accesses */
4320
4320
  index_read_cost= h->index_only_read_time(keynr, (double)rows);
4321
4321
  cost->add_io(index_read_cost, 1 /* Random seeks */);
4322
 
  return FALSE;
 
4322
  return false;
4323
4323
}
4324
4324
 
4325
4325
 
4343
4343
{
4344
4344
  if (nrows)
4345
4345
  {
4346
 
    get_sweep_read_cost(table, nrows, FALSE, cost);
 
4346
    get_sweep_read_cost(table, nrows, false, cost);
4347
4347
    /* Add cost of qsort call: n * log2(n) * cost(rowid_comparison) */
4348
4348
    double cmp_op= rows2double(nrows) * (1.0 / TIME_FOR_COMPARE_ROWID);
4349
4349
    if (cmp_op < 3)
4393
4393
 
4394
4394
  @param table             Table to be accessed
4395
4395
  @param nrows             Number of rows to retrieve
4396
 
  @param interrupted       TRUE <=> Assume that the disk sweep will be
4397
 
                           interrupted by other disk IO. FALSE - otherwise.
 
4396
  @param interrupted       true <=> Assume that the disk sweep will be
 
4397
                           interrupted by other disk IO. false - otherwise.
4398
4398
  @param cost         OUT  The cost.
4399
4399
*/
4400
4400
 
4617
4617
    }
4618
4618
    delete file;
4619
4619
  }
4620
 
  return FALSE;
 
4620
  return false;
4621
4621
}
4622
4622
 
4623
4623
TYPELIB *ha_known_exts(void)
4659
4659
  protocol->store(file, file_len, system_charset_info);
4660
4660
  protocol->store(status, status_len, system_charset_info);
4661
4661
  if (protocol->write())
4662
 
    return TRUE;
4663
 
  return FALSE;
 
4662
    return true;
 
4663
  return false;
4664
4664
}
4665
4665
 
4666
4666
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
4675
4675
 
4676
4676
  if (protocol->send_fields(&field_list,
4677
4677
                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
4678
 
    return TRUE;
 
4678
    return true;
4679
4679
 
4680
4680
  result= db_type->show_status &&
4681
4681
    db_type->show_status(db_type, thd, stat_print, stat) ? 1 : 0;