~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

« back to all changes in this revision

Viewing changes to sql/event_db_repository.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 22:33:55 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120222223355-or06x1euyk8n0ldi
Tags: 5.1.61-0ubuntu0.10.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
* Dropped patches unnecessary with 5.1.61:
  - debian/patches/90_mysql_safer_strmov.dpatch
  - debian/patches/51_ssl_test_certs.dpatch
  - debian/patches/52_CVE-2009-4030.dpatch
  - debian/patches/53_CVE-2009-4484.dpatch
  - debian/patches/54_CVE-2008-7247.dpatch
  - debian/patches/55_CVE-2010-1621.dpatch
  - debian/patches/56_CVE-2010-1850.dpatch
  - debian/patches/57_CVE-2010-1849.dpatch
  - debian/patches/58_CVE-2010-1848.dpatch
  - debian/patches/59_CVE-2010-1626.dpatch
  - debian/patches/60_CVE-2010-2008.dpatch
  - debian/patches/60_CVE-2010-3677.dpatch
  - debian/patches/60_CVE-2010-3678.dpatch
  - debian/patches/60_CVE-2010-3679.dpatch
  - debian/patches/60_CVE-2010-3680.dpatch
  - debian/patches/60_CVE-2010-3681.dpatch
  - debian/patches/60_CVE-2010-3682.dpatch
  - debian/patches/60_CVE-2010-3683.dpatch
  - debian/patches/60_CVE-2010-3833.dpatch
  - debian/patches/60_CVE-2010-3834.dpatch
  - debian/patches/60_CVE-2010-3835.dpatch
  - debian/patches/60_CVE-2010-3836.dpatch
  - debian/patches/60_CVE-2010-3837.dpatch
  - debian/patches/60_CVE-2010-3838.dpatch
  - debian/patches/60_CVE-2010-3839.dpatch
  - debian/patches/60_CVE-2010-3840.dpatch
  - debian/patches/61_disable_longfilename_test.dpatch
  - debian/patches/62_alter_table_fix.dpatch
  - debian/patches/63_cherrypick-upstream-49479.dpatch
  - debian/patches/10_readline_build_fix.dpatch
* debian/mysql-client-5.1.docs: removed EXCEPTIONS-CLIENT file
* debian/mysql-server-5.1.docs,debian/libmysqlclient16.docs,
  debian/libmysqlclient-dev.docs: removed, no longer necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc.
 
1
/*
 
2
   Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
#include "mysql_priv.h"
17
19
#include "event_db_repository.h"
26
28
*/
27
29
 
28
30
static
29
 
const TABLE_FIELD_W_TYPE event_table_fields[ET_FIELD_COUNT] =
 
31
const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] =
30
32
{
31
33
  {
32
34
    { C_STRING_WITH_LEN("db") },
151
153
  }
152
154
};
153
155
 
 
156
static const TABLE_FIELD_DEF
 
157
  event_table_def= {ET_FIELD_COUNT, event_table_fields};
 
158
 
 
159
class Event_db_intact : public Table_check_intact
 
160
{
 
161
protected:
 
162
  void report_error(uint, const char *fmt, ...)
 
163
  {
 
164
    va_list args;
 
165
    va_start(args, fmt);
 
166
    error_log_print(ERROR_LEVEL, fmt, args);
 
167
    va_end(args);
 
168
  }
 
169
};
 
170
 
 
171
/** In case of an error, a message is printed to the error log. */
 
172
static Event_db_intact table_intact;
 
173
 
154
174
 
155
175
/**
156
176
  Puts some data common to CREATE and ALTER EVENT into a row.
208
228
  if (fields[f_num= ET_FIELD_NAME]->store(et->name.str, et->name.length, scs))
209
229
    goto err_truncate;
210
230
 
211
 
  /* both ON_COMPLETION and STATUS are NOT NULL thus not calling set_notnull()*/
 
231
  /* ON_COMPLETION field is NOT NULL thus not calling set_notnull()*/
212
232
  rs|= fields[ET_FIELD_ON_COMPLETION]->store((longlong)et->on_completion, TRUE);
213
 
  rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
 
233
 
 
234
  /*
 
235
    Set STATUS value unconditionally in case of CREATE EVENT.
 
236
    For ALTER EVENT set it only if value of this field was changed.
 
237
    Since STATUS field is NOT NULL call to set_notnull() is not needed.
 
238
  */
 
239
  if (!is_update || et->status_changed)
 
240
    rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
214
241
  rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
215
242
 
216
243
  /*
406
433
  key_copy(key_buf, event_table->record[0], key_info, key_len);
407
434
  if (!(ret= event_table->file->index_read_map(event_table->record[0], key_buf,
408
435
                                               (key_part_map)1,
409
 
                                               HA_READ_PREFIX)))
 
436
                                               HA_READ_KEY_EXACT)))
410
437
  {
411
438
    DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret));
412
439
    do
564
591
 
565
592
  *table= tables.table;
566
593
  tables.table->use_all_columns();
 
594
 
 
595
  if (table_intact.check(*table, &event_table_def))
 
596
  {
 
597
    close_thread_tables(thd);
 
598
    my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0));
 
599
    DBUG_RETURN(TRUE);
 
600
  }
 
601
 
567
602
  DBUG_RETURN(FALSE);
568
603
}
569
604
 
578
613
  only creates a record on disk.
579
614
  @pre The thread handle has no open tables.
580
615
 
581
 
  @param[in,out] thd           THD
582
 
  @param[in]     parse_data    Parsed event definition
583
 
  @param[in]     create_if_not TRUE if IF NOT EXISTS clause was provided
584
 
                               to CREATE EVENT statement
585
 
 
 
616
  @param[in,out] thd                   THD
 
617
  @param[in]     parse_data            Parsed event definition
 
618
  @param[in]     create_if_not         TRUE if IF NOT EXISTS clause was provided
 
619
                                       to CREATE EVENT statement
 
620
  @param[out]    event_already_exists  When method is completed successfully
 
621
                                       set to true if event already exists else
 
622
                                       set to false
586
623
  @retval FALSE  success
587
624
  @retval TRUE   error
588
625
*/
589
626
 
590
627
bool
591
628
Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
592
 
                                  my_bool create_if_not)
 
629
                                  bool create_if_not,
 
630
                                  bool *event_already_exists)
593
631
{
594
632
  int ret= 1;
595
633
  TABLE *table= NULL;
615
653
  {
616
654
    if (create_if_not)
617
655
    {
 
656
      *event_already_exists= true;
618
657
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
619
658
                          ER_EVENT_ALREADY_EXISTS, ER(ER_EVENT_ALREADY_EXISTS),
620
659
                          parse_data->name.str);
622
661
    }
623
662
    else
624
663
      my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), parse_data->name.str);
 
664
 
625
665
    goto end;
626
 
  }
 
666
  } else
 
667
    *event_already_exists= false;
627
668
 
628
669
  DBUG_PRINT("info", ("non-existent, go forward"));
629
670
 
662
703
  if (mysql_event_fill_row(thd, table, parse_data, sp, saved_mode, FALSE))
663
704
    goto end;
664
705
 
665
 
  table->field[ET_FIELD_STATUS]->store((longlong)parse_data->status, TRUE);
666
 
 
667
706
  if ((ret= table->file->ha_write_row(table->record[0])))
668
707
  {
669
708
    table->file->print_error(ret, MYF(0));
1027
1066
  TABLE *table= NULL;
1028
1067
  Field **fields;
1029
1068
  int ret= 1;
 
1069
  bool save_binlog_row_based;
1030
1070
 
1031
1071
  DBUG_ENTER("Event_db_repository::update_timing_fields_for_event");
1032
1072
 
1034
1074
    Turn off row binlogging of event timing updates. These are not used
1035
1075
    for RBR of events replicated to the slave.
1036
1076
  */
1037
 
  if (thd->current_stmt_binlog_row_based)
1038
 
    thd->clear_current_stmt_binlog_row_based();
 
1077
  save_binlog_row_based= thd->current_stmt_binlog_row_based;
 
1078
  thd->clear_current_stmt_binlog_row_based();
1039
1079
 
1040
1080
  DBUG_ASSERT(thd->security_ctx->master_access & SUPER_ACL);
1041
1081
 
1077
1117
end:
1078
1118
  if (table)
1079
1119
    close_thread_tables(thd);
 
1120
  /* Restore the state of binlog format */
 
1121
  thd->current_stmt_binlog_row_based= save_binlog_row_based;
1080
1122
 
1081
1123
  DBUG_RETURN(test(ret));
1082
1124
}
1117
1159
  }
1118
1160
  else
1119
1161
  {
1120
 
    if (table_check_intact(tables.table, MYSQL_DB_FIELD_COUNT,
1121
 
                           mysql_db_table_fields))
 
1162
    if (table_intact.check(tables.table, &mysql_db_table_def))
1122
1163
      ret= 1;
1123
 
    /* in case of an error, the message is printed inside table_check_intact */
1124
1164
 
1125
1165
    close_thread_tables(thd);
1126
1166
  }
1154
1194
  }
1155
1195
  else
1156
1196
  {
1157
 
    if (table_check_intact(tables.table, ET_FIELD_COUNT, event_table_fields))
 
1197
    if (table_intact.check(tables.table, &event_table_def))
1158
1198
      ret= 1;
1159
 
    /* in case of an error, the message is printed inside table_check_intact */
1160
1199
    close_thread_tables(thd);
1161
1200
  }
1162
1201