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

« 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 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 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"
226
228
  if (fields[f_num= ET_FIELD_NAME]->store(et->name.str, et->name.length, scs))
227
229
    goto err_truncate;
228
230
 
229
 
  /* 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()*/
230
232
  rs|= fields[ET_FIELD_ON_COMPLETION]->store((longlong)et->on_completion, TRUE);
231
 
  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);
232
241
  rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
233
242
 
234
243
  /*
424
433
  key_copy(key_buf, event_table->record[0], key_info, key_len);
425
434
  if (!(ret= event_table->file->index_read_map(event_table->record[0], key_buf,
426
435
                                               (key_part_map)1,
427
 
                                               HA_READ_PREFIX)))
 
436
                                               HA_READ_KEY_EXACT)))
428
437
  {
429
438
    DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret));
430
439
    do
582
591
 
583
592
  *table= tables.table;
584
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
 
585
602
  DBUG_RETURN(FALSE);
586
603
}
587
604
 
596
613
  only creates a record on disk.
597
614
  @pre The thread handle has no open tables.
598
615
 
599
 
  @param[in,out] thd           THD
600
 
  @param[in]     parse_data    Parsed event definition
601
 
  @param[in]     create_if_not TRUE if IF NOT EXISTS clause was provided
602
 
                               to CREATE EVENT statement
603
 
 
 
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
604
623
  @retval FALSE  success
605
624
  @retval TRUE   error
606
625
*/
607
626
 
608
627
bool
609
628
Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
610
 
                                  my_bool create_if_not)
 
629
                                  bool create_if_not,
 
630
                                  bool *event_already_exists)
611
631
{
612
632
  int ret= 1;
613
633
  TABLE *table= NULL;
633
653
  {
634
654
    if (create_if_not)
635
655
    {
 
656
      *event_already_exists= true;
636
657
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
637
658
                          ER_EVENT_ALREADY_EXISTS, ER(ER_EVENT_ALREADY_EXISTS),
638
659
                          parse_data->name.str);
640
661
    }
641
662
    else
642
663
      my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), parse_data->name.str);
 
664
 
643
665
    goto end;
644
 
  }
 
666
  } else
 
667
    *event_already_exists= false;
645
668
 
646
669
  DBUG_PRINT("info", ("non-existent, go forward"));
647
670
 
680
703
  if (mysql_event_fill_row(thd, table, parse_data, sp, saved_mode, FALSE))
681
704
    goto end;
682
705
 
683
 
  table->field[ET_FIELD_STATUS]->store((longlong)parse_data->status, TRUE);
684
 
 
685
706
  if ((ret= table->file->ha_write_row(table->record[0])))
686
707
  {
687
708
    table->file->print_error(ret, MYF(0));