~ubuntu-branches/ubuntu/utopic/mariadb-5.5/utopic-security

« back to all changes in this revision

Viewing changes to sql/sql_partition.cc

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-08-27 21:12:36 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140827211236-se41hwfe4xy0hpef
* d/control: Removed Provides: libmysqlclient-dev (Closes: #759309)
* d/control: Removed Provides: libmysqld-dev with same motivation
* Re-introduced tha HPPA build patch as the upstream fix wasn't complete
* Fixed all kFreeBSD build and test suite issues
* Added Italian translation (Closes: #759813)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2005, 2013, Oracle and/or its affiliates.
2
 
   Copyright (c) 2009, 2011, Monty Program Ab.
 
1
/* Copyright (c) 2005, 2014, Oracle and/or its affiliates.
 
2
   Copyright (c) 2009, 2014, SkySQL Ab.
3
3
 
4
4
   This program is free software; you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
3232
3232
  uint num_columns= part_info->part_field_list.elements;
3233
3233
  uint list_index;
3234
3234
  uint min_list_index= 0;
 
3235
  int cmp;
 
3236
  /* Notice that max_list_index = last_index + 1 here! */
3235
3237
  uint max_list_index= part_info->num_list_values;
3236
3238
  DBUG_ENTER("get_partition_id_cols_list_for_endpoint");
3237
3239
 
3238
3240
  /* Find the matching partition (including taking endpoint into account). */
3239
3241
  do
3240
3242
  {
3241
 
    /* Midpoint, adjusted down, so it can never be > last index. */
 
3243
    /* Midpoint, adjusted down, so it can never be >= max_list_index. */
3242
3244
    list_index= (max_list_index + min_list_index) >> 1;
3243
 
    if (cmp_rec_and_tuple_prune(list_col_array + list_index*num_columns,
3244
 
                                nparts, left_endpoint, include_endpoint) > 0)
 
3245
    cmp= cmp_rec_and_tuple_prune(list_col_array + list_index*num_columns,
 
3246
                                 nparts, left_endpoint, include_endpoint);
 
3247
    if (cmp > 0)
 
3248
    {
3245
3249
      min_list_index= list_index + 1;
 
3250
    }
3246
3251
    else
 
3252
    {
3247
3253
      max_list_index= list_index;
 
3254
      if (cmp == 0)
 
3255
        break;
 
3256
    }
3248
3257
  } while (max_list_index > min_list_index);
3249
3258
  list_index= max_list_index;
3250
3259
 
3261
3270
                                           nparts, left_endpoint,
3262
3271
                                           include_endpoint)));
3263
3272
 
3264
 
  if (!left_endpoint)
3265
 
  {
3266
 
    /* Set the end after this list tuple if not already after the last. */
3267
 
    if (list_index < part_info->num_parts)
3268
 
      list_index++;
3269
 
  }
 
3273
  /* Include the right endpoint if not already passed end of array. */
 
3274
  if (!left_endpoint && include_endpoint && cmp == 0 &&
 
3275
      list_index < part_info->num_list_values)
 
3276
    list_index++;
3270
3277
 
3271
3278
  DBUG_RETURN(list_index);
3272
3279
}
5494
5501
       There was no partitioning before and no partitioning defined.
5495
5502
       Obviously no work needed.
5496
5503
    */
5497
 
    if (table->part_info)
 
5504
    partition_info *tab_part_info= table->part_info;
 
5505
 
 
5506
    if (tab_part_info)
5498
5507
    {
5499
5508
      if (alter_info->flags & ALTER_REMOVE_PARTITIONING)
5500
5509
      {
5502
5511
        if (!(create_info->used_fields & HA_CREATE_USED_ENGINE))
5503
5512
        {
5504
5513
          DBUG_PRINT("info", ("No explicit engine used"));
5505
 
          create_info->db_type= table->part_info->default_engine_type;
 
5514
          create_info->db_type= tab_part_info->default_engine_type;
5506
5515
        }
5507
5516
        DBUG_PRINT("info", ("New engine type: %s",
5508
5517
                   ha_resolve_storage_engine_name(create_info->db_type)));
5514
5523
        /*
5515
5524
          Retain partitioning but possibly with a new storage engine
5516
5525
          beneath.
 
5526
 
 
5527
          Create a copy of TABLE::part_info to be able to modify it freely.
5517
5528
        */
5518
 
        thd->work_part_info= table->part_info;
 
5529
        if (!(tab_part_info= tab_part_info->get_clone()))
 
5530
          DBUG_RETURN(TRUE);
 
5531
        thd->work_part_info= tab_part_info;
5519
5532
        if (create_info->used_fields & HA_CREATE_USED_ENGINE &&
5520
 
            create_info->db_type != table->part_info->default_engine_type)
 
5533
            create_info->db_type != tab_part_info->default_engine_type)
5521
5534
        {
5522
5535
          /*
5523
5536
            Make sure change of engine happens to all partitions.
5524
5537
          */
5525
5538
          DBUG_PRINT("info", ("partition changed"));
5526
 
          if (table->part_info->is_auto_partitioned)
 
5539
          if (tab_part_info->is_auto_partitioned)
5527
5540
          {
5528
5541
            /*
5529
5542
              If the user originally didn't specify partitioning to be
5551
5564
        Need to cater for engine types that can handle partition without
5552
5565
        using the partition handler.
5553
5566
      */
5554
 
      if (part_info != table->part_info)
 
5567
      if (part_info != tab_part_info)
5555
5568
      {
5556
5569
        if (part_info->fix_parser_data(thd))
5557
5570
        {
5579
5592
        part_info->default_engine_type= create_info->db_type;
5580
5593
      else
5581
5594
      {
5582
 
        if (table->part_info)
5583
 
          part_info->default_engine_type= table->part_info->default_engine_type;
 
5595
        if (tab_part_info)
 
5596
          part_info->default_engine_type= tab_part_info->default_engine_type;
5584
5597
        else
5585
5598
          part_info->default_engine_type= create_info->db_type;
5586
5599
      }
7423
7436
  field= val->part_info->part_field_array + n_vals_in_rec;
7424
7437
  if (!(*field))
7425
7438
  {
7426
 
    /*
7427
 
      Full match, if right endpoint and not including the endpoint,
7428
 
      (rec < part) return lesser.
7429
 
    */
7430
 
    if (!is_left_endpoint && !include_endpoint)
7431
 
      return -4;
 
7439
    /* Full match. Only equal if including endpoint. */
 
7440
    if (include_endpoint)
 
7441
      return 0;
7432
7442
 
7433
 
    /* Otherwise they are equal! */
7434
 
    return 0;
 
7443
    if (is_left_endpoint)
 
7444
      return +4;     /* Start of range, part_tuple < rec, return higher. */
 
7445
    return -4;     /* End of range, rec < part_tupe, return lesser. */
7435
7446
  }
7436
7447
  /*
7437
7448
    The prefix is equal and there are more partition columns to compare.