~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/sql_parse.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
536
536
    query= (char *) thd->memdup_w_gap(buff, length + 1,
537
537
                                      thd->db_length + 1 +
538
538
                                      QUERY_CACHE_FLAGS_SIZE);
 
539
    size_t db_len= 0;
 
540
    memcpy(query + length + 1, (char *) &db_len, sizeof(size_t));
539
541
    thd->set_query_and_id(query, length, thd->charset(), next_query_id());
540
542
    DBUG_PRINT("query",("%-.4096s",thd->query()));
541
543
#if defined(ENABLED_PROFILING)
1218
1220
  case COM_REFRESH:
1219
1221
  {
1220
1222
    int not_used;
 
1223
 
 
1224
    /*
 
1225
      Initialize thd->lex since it's used in many base functions, such as
 
1226
      open_tables(). Otherwise, it remains unitialized and may cause crash
 
1227
      during execution of COM_REFRESH.
 
1228
    */
 
1229
    lex_start(thd);
 
1230
    
1221
1231
    status_var_increment(thd->status_var.com_stat[SQLCOM_FLUSH]);
1222
1232
    ulong options= (ulong) (uchar) packet[0];
1223
1233
    if (trans_commit_implicit(thd))
1629
1639
    pos--;
1630
1640
    packet_length--;
1631
1641
  }
1632
 
  /* We must allocate some extra memory for query cache */
 
1642
  /* We must allocate some extra memory for query cache 
 
1643
 
 
1644
    The query buffer layout is:
 
1645
       buffer :==
 
1646
            <statement>   The input statement(s)
 
1647
            '\0'          Terminating null char  (1 byte)
 
1648
            <length>      Length of following current database name (size_t)
 
1649
            <db_name>     Name of current database
 
1650
            <flags>       Flags struct
 
1651
  */
1633
1652
  if (! (query= (char*) thd->memdup_w_gap(packet,
1634
1653
                                          packet_length,
1635
 
                                          1 + thd->db_length +
 
1654
                                          1 + sizeof(size_t) + thd->db_length +
1636
1655
                                          QUERY_CACHE_FLAGS_SIZE)))
1637
1656
      return TRUE;
1638
1657
  query[packet_length]= '\0';
 
1658
  /*
 
1659
    Space to hold the name of the current database is allocated.  We
 
1660
    also store this length, in case current database is changed during
 
1661
    execution.  We might need to reallocate the 'query' buffer
 
1662
  */
 
1663
  char *len_pos = (query + packet_length + 1);
 
1664
  memcpy(len_pos, (char *) &thd->db_length, sizeof(size_t));
 
1665
    
1639
1666
  thd->set_query(query, packet_length);
1640
1667
 
1641
1668
  /* Reclaim some memory */
2387
2414
      select_result *result;
2388
2415
 
2389
2416
      /*
 
2417
        CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless
 
2418
        ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore
 
2419
        use row based logging if mixed or row based logging is available.
 
2420
        TODO: Check if the order of the output of the select statement is
 
2421
        deterministic. Waiting for BUG#42415
 
2422
      */
 
2423
      if(lex->ignore)
 
2424
        lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_IGNORE_SELECT);
 
2425
      
 
2426
      if(lex->duplicates == DUP_REPLACE)
 
2427
        lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT);
 
2428
 
 
2429
      /*
2390
2430
        If:
2391
2431
        a) we inside an SP and there was NAME_CONST substitution,
2392
2432
        b) binlogging is on (STMT mode),
2720
2760
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
2721
2761
    if (update_precheck(thd, all_tables))
2722
2762
      break;
 
2763
 
 
2764
    /*
 
2765
      UPDATE IGNORE can be unsafe. We therefore use row based
 
2766
      logging if mixed or row based logging is available.
 
2767
      TODO: Check if the order of the output of the select statement is
 
2768
      deterministic. Waiting for BUG#42415
 
2769
    */
 
2770
    if (lex->ignore)
 
2771
      lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UPDATE_IGNORE);
 
2772
 
2723
2773
    DBUG_ASSERT(select_lex->offset_limit == 0);
2724
2774
    unit->set_limit(select_lex);
2725
2775
    MYSQL_UPDATE_START(thd->query());
2838
2888
      {
2839
2889
        Incident_log_event ev(thd, incident);
2840
2890
        (void) mysql_bin_log.write(&ev);        /* error is ignored */
2841
 
        if (mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE))
 
2891
        if (mysql_bin_log.rotate_and_purge(true))
2842
2892
        {
2843
2893
          res= 1;
2844
2894
          break;
2886
2936
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
2887
2937
    if ((res= insert_precheck(thd, all_tables)))
2888
2938
      break;
 
2939
    /*
 
2940
      INSERT...SELECT...ON DUPLICATE KEY UPDATE/REPLACE SELECT/
 
2941
      INSERT...IGNORE...SELECT can be unsafe, unless ORDER BY PRIMARY KEY
 
2942
      clause is used in SELECT statement. We therefore use row based
 
2943
      logging if mixed or row based logging is available.
 
2944
      TODO: Check if the order of the output of the select statement is
 
2945
      deterministic. Waiting for BUG#42415
 
2946
    */
 
2947
    if (lex->sql_command == SQLCOM_INSERT_SELECT &&
 
2948
        lex->duplicates == DUP_UPDATE)
 
2949
      lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE);
 
2950
 
 
2951
    if (lex->sql_command == SQLCOM_INSERT_SELECT && lex->ignore)
 
2952
      lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_IGNORE_SELECT);
 
2953
 
 
2954
    if (lex->sql_command == SQLCOM_REPLACE_SELECT)
 
2955
      lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_REPLACE_SELECT);
2889
2956
 
2890
2957
    /* Fix lock for first table */
2891
2958
    if (first_table->lock_type == TL_WRITE_DELAYED)