~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to sql/handler.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
 
1
/* Copyright (c) 2000, 2011, 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
275
275
  }
276
276
  else
277
277
  {
278
 
    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(ha_partition));
 
278
    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(ha_partition)));
279
279
  }
280
280
  DBUG_RETURN(((handler*) partition));
281
281
}
1192
1192
    error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0;
1193
1193
    DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE(););
1194
1194
    if (cookie)
1195
 
      tc_log->unlog(cookie, xid);
 
1195
      if(tc_log->unlog(cookie, xid))
 
1196
      {
 
1197
        error= 2;
 
1198
        goto end;
 
1199
      }
1196
1200
    DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););
1197
1201
end:
1198
1202
    if (rw_trans)
1600
1604
  }
1601
1605
  if (!info.list)
1602
1606
  {
1603
 
    sql_print_error(ER(ER_OUTOFMEMORY), info.len*sizeof(XID));
 
1607
    sql_print_error(ER(ER_OUTOFMEMORY),
 
1608
                    static_cast<int>(info.len*sizeof(XID)));
1604
1609
    DBUG_RETURN(1);
1605
1610
  }
1606
1611
 
2033
2038
/****************************************************************************
2034
2039
** General handler functions
2035
2040
****************************************************************************/
2036
 
handler *handler::clone(MEM_ROOT *mem_root)
 
2041
handler *handler::clone(const char *name, MEM_ROOT *mem_root)
2037
2042
{
2038
 
  handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
 
2043
  handler *new_handler= get_new_handler(table->s, mem_root, ht);
2039
2044
  /*
2040
2045
    Allocate handler->ref here because otherwise ha_open will allocate it
2041
2046
    on this->table->mem_root and we will not be able to reclaim that memory 
2042
2047
    when the clone handler object is destroyed.
2043
2048
  */
2044
 
  if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
2045
 
    return NULL;
2046
 
  if (new_handler && !new_handler->ha_open(table,
2047
 
                                           table->s->normalized_path.str,
2048
 
                                           table->db_stat,
2049
 
                                           HA_OPEN_IGNORE_IF_LOCKED))
2050
 
    return new_handler;
2051
 
  return NULL;
 
2049
  if (new_handler &&
 
2050
     !(new_handler->ref= (uchar*) alloc_root(mem_root,
 
2051
                                             ALIGN_SIZE(ref_length)*2)))
 
2052
    new_handler= NULL;
 
2053
  /*
 
2054
    TODO: Implement a more efficient way to have more than one index open for
 
2055
    the same table instance. The ha_open call is not cachable for clone.
 
2056
  */
 
2057
  if (new_handler && new_handler->ha_open(table,
 
2058
                                          name,
 
2059
                                          table->db_stat,
 
2060
                                          HA_OPEN_IGNORE_IF_LOCKED))
 
2061
    new_handler= NULL;
 
2062
 
 
2063
  return new_handler;
2052
2064
}
2053
2065
 
2054
2066
 
2166
2178
  computes the lowest number
2167
2179
  - strictly greater than "nr"
2168
2180
  - of the form: auto_increment_offset + N * auto_increment_increment
2169
 
 
 
2181
  If overflow happened then return MAX_ULONGLONG value as an
 
2182
  indication of overflow.
2170
2183
  In most cases increment= offset= 1, in which case we get:
2171
2184
  @verbatim 1,2,3,4,5,... @endverbatim
2172
2185
    If increment=10 and offset=5 and previous number is 1, we get:
2175
2188
inline ulonglong
2176
2189
compute_next_insert_id(ulonglong nr,struct system_variables *variables)
2177
2190
{
 
2191
  const ulonglong save_nr= nr;
 
2192
 
2178
2193
  if (variables->auto_increment_increment == 1)
2179
 
    return (nr+1); // optimization of the formula below
2180
 
  nr= (((nr+ variables->auto_increment_increment -
2181
 
         variables->auto_increment_offset)) /
2182
 
       (ulonglong) variables->auto_increment_increment);
2183
 
  return (nr* (ulonglong) variables->auto_increment_increment +
2184
 
          variables->auto_increment_offset);
 
2194
    nr= nr + 1; // optimization of the formula below
 
2195
  else
 
2196
  {
 
2197
    nr= (((nr+ variables->auto_increment_increment -
 
2198
           variables->auto_increment_offset)) /
 
2199
         (ulonglong) variables->auto_increment_increment);
 
2200
    nr= (nr* (ulonglong) variables->auto_increment_increment +
 
2201
         variables->auto_increment_offset);
 
2202
  }
 
2203
 
 
2204
  if (unlikely(nr <= save_nr))
 
2205
    return ULONGLONG_MAX;
 
2206
 
 
2207
  return nr;
2185
2208
}
2186
2209
 
2187
2210
 
2392
2415
                         variables->auto_increment_increment,
2393
2416
                         nb_desired_values, &nr,
2394
2417
                         &nb_reserved_values);
2395
 
      if (nr == ~(ulonglong) 0)
 
2418
      if (nr == ULONGLONG_MAX)
2396
2419
        DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED);  // Mark failure
2397
2420
 
2398
2421
      /*
2423
2446
    }
2424
2447
  }
2425
2448
 
 
2449
  if (unlikely(nr == ULONGLONG_MAX))
 
2450
      DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); 
 
2451
 
2426
2452
  DBUG_PRINT("info",("auto_increment: %lu", (ulong) nr));
2427
2453
 
2428
2454
  if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
2666
2692
      char key[MAX_KEY_LENGTH];
2667
2693
      String str(key,sizeof(key),system_charset_info);
2668
2694
      /* Table is opened and defined at this point */
2669
 
      key_unpack(&str,table,(uint) key_nr);
 
2695
      key_unpack(&str,table,0 /* Use 0 instead of key_nr because key_nr
 
2696
                 is a key number in the child FK table, not in our 'table'. See
 
2697
                 Bug#12661768 UPDATE IGNORE CRASHES SERVER IF TABLE IS INNODB
 
2698
                 AND IT IS PARENT FOR OTHER ONE
 
2699
                 This bug gets a better fix in MySQL 5.6, but it is too risky
 
2700
                 to get that in 5.1 and 5.5 (extending the handler interface
 
2701
                 and adding new error message codes */);
2670
2702
      max_length= (MYSQL_ERRMSG_SIZE-
2671
2703
                   (uint) strlen(ER(ER_FOREIGN_DUPLICATE_KEY)));
2672
2704
      if (str.length() >= max_length)
4639
4671
  free_io_cache(table);
4640
4672
  /* reset the bitmaps to point to defaults */
4641
4673
  table->default_column_bitmaps();
 
4674
  pushed_cond= NULL;
4642
4675
  DBUG_RETURN(reset());
4643
4676
}
4644
4677