~ubuntu-branches/ubuntu/oneiric/mysql-5.1/oneiric-updates

« back to all changes in this revision

Viewing changes to sql/sql_partition.cc

  • Committer: Package Import Robot
  • Author(s): Seth Arnold
  • Date: 2013-04-18 17:10:57 UTC
  • mfrom: (1.5.3)
  • Revision ID: package-import@ubuntu.com-20130418171057-21exi1cs3ctn0g2x
Tags: 5.1.69-0ubuntu0.11.10.1
* SECURITY UPDATE: Update to 5.1.69 to fix security issues (LP: #1170516)
  - http://www.oracle.com/technetwork/topics/security/cpuapr2013-1899555.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 
1
/* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
6793
6793
  get_endpoint_func  UNINIT_VAR(get_endpoint);
6794
6794
  bool               can_match_multiple_values;  /* is not '=' */
6795
6795
  uint field_len= field->pack_length_in_rec();
 
6796
  MYSQL_TIME start_date;
 
6797
  bool check_zero_dates= false;
 
6798
  bool zero_in_start_date= true;
6796
6799
  part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE;
6797
6800
 
6798
6801
  if (part_info->part_type == RANGE_PARTITION)
6844
6847
    {
6845
6848
      /* col is NOT NULL, but F(col) can return NULL, add NULL partition */
6846
6849
      part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE;
 
6850
      check_zero_dates= true;
6847
6851
    }
6848
6852
  }
6849
6853
 
6887
6891
        return 1;
6888
6892
      }
6889
6893
      part_iter->part_nums.cur= part_iter->part_nums.start;
 
6894
      if (check_zero_dates && !part_info->part_expr->null_value)
 
6895
      {
 
6896
        if (!(flags & NO_MAX_RANGE) &&
 
6897
            (field->type() == MYSQL_TYPE_DATE ||
 
6898
             field->type() == MYSQL_TYPE_DATETIME))
 
6899
        {
 
6900
          /* Monotonic, but return NULL for dates with zeros in month/day. */
 
6901
          zero_in_start_date= field->get_date(&start_date, 0);
 
6902
          DBUG_PRINT("info", ("zero start %u %04d-%02d-%02d",
 
6903
                              zero_in_start_date, start_date.year,
 
6904
                              start_date.month, start_date.day));
 
6905
        }
 
6906
      }
6890
6907
      if (part_iter->part_nums.start == max_endpoint_val)
6891
6908
        return 0; /* No partitions */
6892
6909
    }
6900
6917
    store_key_image_to_rec(field, max_value, field_len);
6901
6918
    bool include_endp= !test(flags & NEAR_MAX);
6902
6919
    part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp);
 
6920
    if (check_zero_dates &&
 
6921
        !zero_in_start_date &&
 
6922
        !part_info->part_expr->null_value)
 
6923
    {
 
6924
      MYSQL_TIME end_date;
 
6925
      bool zero_in_end_date= field->get_date(&end_date, 0);
 
6926
      /*
 
6927
        This is an optimization for TO_DAYS() to avoid scanning the NULL
 
6928
        partition for ranges that cannot include a date with 0 as
 
6929
        month/day.
 
6930
      */
 
6931
      DBUG_PRINT("info", ("zero end %u %04d-%02d-%02d",
 
6932
                          zero_in_end_date,
 
6933
                          end_date.year, end_date.month, end_date.day));
 
6934
      DBUG_ASSERT(!memcmp(((Item_func*) part_info->part_expr)->func_name(),
 
6935
                          "to_days", 7));
 
6936
      if (!zero_in_end_date &&
 
6937
          start_date.month == end_date.month &&
 
6938
          start_date.year == end_date.year)
 
6939
        part_iter->ret_null_part= part_iter->ret_null_part_orig= false;
 
6940
    }
6903
6941
    if (part_iter->part_nums.start >= part_iter->part_nums.end &&
6904
6942
        !part_iter->ret_null_part)
6905
6943
      return 0; /* No partitions */