~ubuntu-branches/ubuntu/quantal/mysql-5.5/quantal-security

« back to all changes in this revision

Viewing changes to sql/sql_table.cc

  • Committer: Package Import Robot
  • Author(s): Seth Arnold
  • Date: 2013-04-18 18:15:39 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20130418181539-7uo1w041b4h2ulbs
Tags: 5.5.31-0ubuntu0.12.10.1
* SECURITY UPDATE: Update to 5.5.31 to fix security issues (LP: #1170516)
  - http://www.oracle.com/technetwork/topics/security/cpuapr2013-1899555.html
* debian/patches/71_disable_rpl_tests.patch: refreshed.
* debian/patches/fix-mysqldump-test.patch: removed, fixed differently
  upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 
2
   Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3
3
 
4
4
   This program is free software; you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
650
650
 
651
651
struct st_global_ddl_log
652
652
{
653
 
  /*
654
 
    We need to adjust buffer size to be able to handle downgrades/upgrades
655
 
    where IO_SIZE has changed. We'll set the buffer size such that we can
656
 
    handle that the buffer size was upto 4 times bigger in the version
657
 
    that wrote the DDL log.
658
 
  */
659
 
  char file_entry_buf[4*IO_SIZE];
660
653
  char file_name_str[FN_REFLEN];
661
654
  char *file_name;
662
655
  DDL_LOG_MEMORY_ENTRY *first_free;
684
677
#define DDL_LOG_NUM_ENTRY_POS 0
685
678
#define DDL_LOG_NAME_LEN_POS 4
686
679
#define DDL_LOG_IO_SIZE_POS 8
687
 
 
688
 
/*
689
 
  Read one entry from ddl log file
690
 
  SYNOPSIS
691
 
    read_ddl_log_file_entry()
692
 
    entry_no                     Entry number to read
693
 
  RETURN VALUES
694
 
    TRUE                         Error
695
 
    FALSE                        Success
 
680
#define DDL_LOG_HEADER_SIZE 12
 
681
 
 
682
/**
 
683
  Read one entry from ddl log file.
 
684
  @param[out]  file_entry_buf  Buffer to read into
 
685
  @param       entry_no        Entry number to read
 
686
  @param       size            Number of bytes of the entry to read
 
687
 
 
688
  @return Operation status
 
689
    @retval true   Error
 
690
    @retval false  Success
696
691
*/
697
692
 
698
 
static bool read_ddl_log_file_entry(uint entry_no)
 
693
static bool read_ddl_log_file_entry(uchar *file_entry_buf,
 
694
                                    uint entry_no,
 
695
                                    uint size)
699
696
{
700
697
  bool error= FALSE;
701
698
  File file_id= global_ddl_log.file_id;
702
 
  uchar *file_entry_buf= (uchar*)global_ddl_log.file_entry_buf;
703
699
  uint io_size= global_ddl_log.io_size;
704
700
  DBUG_ENTER("read_ddl_log_file_entry");
 
701
  DBUG_ASSERT(io_size >= size);
705
702
 
706
 
  if (mysql_file_pread(file_id, file_entry_buf, io_size, io_size * entry_no,
707
 
                       MYF(MY_WME)) != io_size)
 
703
  if (mysql_file_pread(file_id, file_entry_buf, size, io_size * entry_no,
 
704
                       MYF(MY_WME)) != size)
708
705
    error= TRUE;
709
706
  DBUG_RETURN(error);
710
707
}
711
708
 
712
709
 
713
 
/*
714
 
  Write one entry from ddl log file
715
 
  SYNOPSIS
716
 
    write_ddl_log_file_entry()
717
 
    entry_no                     Entry number to write
718
 
  RETURN VALUES
719
 
    TRUE                         Error
720
 
    FALSE                        Success
 
710
/**
 
711
  Write one entry to ddl log file.
 
712
 
 
713
  @param  file_entry_buf  Buffer to write
 
714
  @param  entry_no        Entry number to write
 
715
  @param  size            Number of bytes of the entry to write
 
716
 
 
717
  @return Operation status
 
718
    @retval true   Error
 
719
    @retval false  Success
721
720
*/
722
721
 
723
 
static bool write_ddl_log_file_entry(uint entry_no)
 
722
static bool write_ddl_log_file_entry(uchar *file_entry_buf,
 
723
                                     uint entry_no,
 
724
                                     uint size)
724
725
{
725
726
  bool error= FALSE;
726
727
  File file_id= global_ddl_log.file_id;
727
 
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
 
728
  uint io_size= global_ddl_log.io_size;
728
729
  DBUG_ENTER("write_ddl_log_file_entry");
 
730
  DBUG_ASSERT(io_size >= size);
729
731
 
730
 
  if (mysql_file_pwrite(file_id, (uchar*)file_entry_buf,
731
 
                        IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE)
 
732
  if (mysql_file_pwrite(file_id, file_entry_buf, size,
 
733
                        io_size * entry_no, MYF(MY_WME)) != size)
732
734
    error= TRUE;
733
735
  DBUG_RETURN(error);
734
736
}
747
749
{
748
750
  uint16 const_var;
749
751
  bool error= FALSE;
 
752
  uchar file_entry_buf[DDL_LOG_HEADER_SIZE];
750
753
  DBUG_ENTER("write_ddl_log_header");
 
754
  DBUG_ASSERT((DDL_LOG_NAME_POS + 3 * global_ddl_log.name_len)
 
755
                <= global_ddl_log.io_size);
751
756
 
752
 
  int4store(&global_ddl_log.file_entry_buf[DDL_LOG_NUM_ENTRY_POS],
 
757
  int4store(&file_entry_buf[DDL_LOG_NUM_ENTRY_POS],
753
758
            global_ddl_log.num_entries);
754
 
  const_var= FN_LEN;
755
 
  int4store(&global_ddl_log.file_entry_buf[DDL_LOG_NAME_LEN_POS],
756
 
            (ulong) const_var);
757
 
  const_var= IO_SIZE;
758
 
  int4store(&global_ddl_log.file_entry_buf[DDL_LOG_IO_SIZE_POS],
759
 
            (ulong) const_var);
760
 
  if (write_ddl_log_file_entry(0UL))
 
759
  const_var= global_ddl_log.name_len;
 
760
  int4store(&file_entry_buf[DDL_LOG_NAME_LEN_POS],
 
761
            (ulong) const_var);
 
762
  const_var= global_ddl_log.io_size;
 
763
  int4store(&file_entry_buf[DDL_LOG_IO_SIZE_POS],
 
764
            (ulong) const_var);
 
765
  if (write_ddl_log_file_entry(file_entry_buf, 0UL, DDL_LOG_HEADER_SIZE))
761
766
  {
762
767
    sql_print_error("Error writing ddl log header");
763
768
    DBUG_RETURN(TRUE);
797
802
 
798
803
static uint read_ddl_log_header()
799
804
{
800
 
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
 
805
  char file_entry_buf[DDL_LOG_HEADER_SIZE];
801
806
  char file_name[FN_REFLEN];
802
807
  uint entry_no;
803
808
  bool successful_open= FALSE;
804
809
  DBUG_ENTER("read_ddl_log_header");
 
810
  DBUG_ASSERT(global_ddl_log.io_size <= IO_SIZE);
805
811
 
806
812
  create_ddl_log_file_name(file_name);
807
813
  if ((global_ddl_log.file_id= mysql_file_open(key_file_global_ddl_log,
808
814
                                               file_name,
809
815
                                               O_RDWR | O_BINARY, MYF(0))) >= 0)
810
816
  {
811
 
    if (read_ddl_log_file_entry(0UL))
 
817
    if (read_ddl_log_file_entry((uchar *) file_entry_buf, 0UL,
 
818
                                DDL_LOG_HEADER_SIZE))
812
819
    {
813
820
      /* Write message into error log */
814
821
      sql_print_error("Failed to read ddl log file in recovery");
821
828
    entry_no= uint4korr(&file_entry_buf[DDL_LOG_NUM_ENTRY_POS]);
822
829
    global_ddl_log.name_len= uint4korr(&file_entry_buf[DDL_LOG_NAME_LEN_POS]);
823
830
    global_ddl_log.io_size= uint4korr(&file_entry_buf[DDL_LOG_IO_SIZE_POS]);
824
 
    DBUG_ASSERT(global_ddl_log.io_size <=
825
 
                sizeof(global_ddl_log.file_entry_buf));
826
831
  }
827
832
  else
828
833
  {
837
842
}
838
843
 
839
844
 
840
 
/*
841
 
  Read a ddl log entry
842
 
  SYNOPSIS
843
 
    read_ddl_log_entry()
844
 
    read_entry               Number of entry to read
845
 
    out:entry_info           Information from entry
846
 
  RETURN VALUES
847
 
    TRUE                     Error
848
 
    FALSE                    Success
849
 
  DESCRIPTION
850
 
    Read a specified entry in the ddl log
 
845
/**
 
846
  Set ddl log entry struct from buffer
 
847
  @param read_entry      Entry number
 
848
  @param file_entry_buf  Buffer to use
 
849
  @param ddl_log_entry   Entry to be set
 
850
 
 
851
  @note Pointers in ddl_log_entry will point into file_entry_buf!
851
852
*/
852
853
 
853
 
bool read_ddl_log_entry(uint read_entry, DDL_LOG_ENTRY *ddl_log_entry)
 
854
static void set_ddl_log_entry_from_buf(uint read_entry,
 
855
                                       uchar *file_entry_buf,
 
856
                                       DDL_LOG_ENTRY *ddl_log_entry)
854
857
{
855
 
  char *file_entry_buf= (char*)&global_ddl_log.file_entry_buf;
856
858
  uint inx;
857
859
  uchar single_char;
858
 
  DBUG_ENTER("read_ddl_log_entry");
859
 
 
860
 
  if (read_ddl_log_file_entry(read_entry))
861
 
  {
862
 
    DBUG_RETURN(TRUE);
863
 
  }
 
860
  DBUG_ENTER("set_ddl_log_entry_from_buf");
864
861
  ddl_log_entry->entry_pos= read_entry;
865
862
  single_char= file_entry_buf[DDL_LOG_ENTRY_TYPE_POS];
866
863
  ddl_log_entry->entry_type= (enum ddl_log_entry_code)single_char;
868
865
  ddl_log_entry->action_type= (enum ddl_log_action_code)single_char;
869
866
  ddl_log_entry->phase= file_entry_buf[DDL_LOG_PHASE_POS];
870
867
  ddl_log_entry->next_entry= uint4korr(&file_entry_buf[DDL_LOG_NEXT_ENTRY_POS]);
871
 
  ddl_log_entry->name= &file_entry_buf[DDL_LOG_NAME_POS];
 
868
  ddl_log_entry->name= (char*) &file_entry_buf[DDL_LOG_NAME_POS];
872
869
  inx= DDL_LOG_NAME_POS + global_ddl_log.name_len;
873
 
  ddl_log_entry->from_name= &file_entry_buf[inx];
 
870
  ddl_log_entry->from_name= (char*) &file_entry_buf[inx];
874
871
  inx+= global_ddl_log.name_len;
875
 
  ddl_log_entry->handler_name= &file_entry_buf[inx];
876
 
  DBUG_RETURN(FALSE);
 
872
  ddl_log_entry->handler_name= (char*) &file_entry_buf[inx];
 
873
  DBUG_VOID_RETURN;
877
874
}
878
 
 
 
875
 
879
876
 
880
877
/*
881
878
  Initialise ddl log
1078
1075
  DDL_LOG_MEMORY_ENTRY *first_used= global_ddl_log.first_used;
1079
1076
  DBUG_ENTER("get_free_ddl_log_entry");
1080
1077
 
 
1078
  mysql_mutex_assert_owner(&LOCK_gdl);
1081
1079
  if (global_ddl_log.first_free == NULL)
1082
1080
  {
1083
1081
    if (!(used_entry= (DDL_LOG_MEMORY_ENTRY*)my_malloc(
1135
1133
                         DDL_LOG_MEMORY_ENTRY **active_entry)
1136
1134
{
1137
1135
  bool error, write_header;
 
1136
  char file_entry_buf[IO_SIZE];
1138
1137
  DBUG_ENTER("write_ddl_log_entry");
1139
1138
 
1140
1139
  if (init_ddl_log())
1141
1140
  {
1142
1141
    DBUG_RETURN(TRUE);
1143
1142
  }
1144
 
  global_ddl_log.file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]=
 
1143
  memset(file_entry_buf, 0, sizeof(file_entry_buf));
 
1144
  file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]=
1145
1145
                                    (char)DDL_LOG_ENTRY_CODE;
1146
 
  global_ddl_log.file_entry_buf[DDL_LOG_ACTION_TYPE_POS]=
 
1146
  file_entry_buf[DDL_LOG_ACTION_TYPE_POS]=
1147
1147
                                    (char)ddl_log_entry->action_type;
1148
 
  global_ddl_log.file_entry_buf[DDL_LOG_PHASE_POS]= 0;
1149
 
  int4store(&global_ddl_log.file_entry_buf[DDL_LOG_NEXT_ENTRY_POS],
 
1148
  file_entry_buf[DDL_LOG_PHASE_POS]= 0;
 
1149
  int4store(&file_entry_buf[DDL_LOG_NEXT_ENTRY_POS],
1150
1150
            ddl_log_entry->next_entry);
1151
 
  DBUG_ASSERT(strlen(ddl_log_entry->name) < FN_LEN);
1152
 
  strmake(&global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS],
1153
 
          ddl_log_entry->name, FN_LEN - 1);
 
1151
  DBUG_ASSERT(strlen(ddl_log_entry->name) < global_ddl_log.name_len);
 
1152
  strmake(&file_entry_buf[DDL_LOG_NAME_POS], ddl_log_entry->name,
 
1153
          global_ddl_log.name_len - 1);
1154
1154
  if (ddl_log_entry->action_type == DDL_LOG_RENAME_ACTION ||
1155
1155
      ddl_log_entry->action_type == DDL_LOG_REPLACE_ACTION)
1156
1156
  {
1157
 
    DBUG_ASSERT(strlen(ddl_log_entry->from_name) < FN_LEN);
1158
 
    strmake(&global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS + FN_LEN],
1159
 
          ddl_log_entry->from_name, FN_LEN - 1);
 
1157
    DBUG_ASSERT(strlen(ddl_log_entry->from_name) < global_ddl_log.name_len);
 
1158
    strmake(&file_entry_buf[DDL_LOG_NAME_POS + global_ddl_log.name_len],
 
1159
            ddl_log_entry->from_name, global_ddl_log.name_len - 1);
1160
1160
  }
1161
1161
  else
1162
 
    global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS + FN_LEN]= 0;
1163
 
  DBUG_ASSERT(strlen(ddl_log_entry->handler_name) < FN_LEN);
1164
 
  strmake(&global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS + (2*FN_LEN)],
1165
 
          ddl_log_entry->handler_name, FN_LEN - 1);
 
1162
    file_entry_buf[DDL_LOG_NAME_POS + global_ddl_log.name_len]= 0;
 
1163
  DBUG_ASSERT(strlen(ddl_log_entry->handler_name) < global_ddl_log.name_len);
 
1164
  strmake(&file_entry_buf[DDL_LOG_NAME_POS + (2*global_ddl_log.name_len)],
 
1165
          ddl_log_entry->handler_name, global_ddl_log.name_len - 1);
1166
1166
  if (get_free_ddl_log_entry(active_entry, &write_header))
1167
1167
  {
1168
1168
    DBUG_RETURN(TRUE);
1170
1170
  error= FALSE;
1171
1171
  DBUG_PRINT("ddl_log",
1172
1172
             ("write type %c next %u name '%s' from_name '%s' handler '%s'",
1173
 
             (char) global_ddl_log.file_entry_buf[DDL_LOG_ACTION_TYPE_POS],
 
1173
             (char) file_entry_buf[DDL_LOG_ACTION_TYPE_POS],
1174
1174
             ddl_log_entry->next_entry,
1175
 
             (char*) &global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS],
1176
 
             (char*) &global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS
1177
 
                                                    + FN_LEN],
1178
 
             (char*) &global_ddl_log.file_entry_buf[DDL_LOG_NAME_POS
1179
 
                                                    + (2*FN_LEN)]));
1180
 
  if (write_ddl_log_file_entry((*active_entry)->entry_pos))
 
1175
             (char*) &file_entry_buf[DDL_LOG_NAME_POS],
 
1176
             (char*) &file_entry_buf[DDL_LOG_NAME_POS +
 
1177
                                     global_ddl_log.name_len],
 
1178
             (char*) &file_entry_buf[DDL_LOG_NAME_POS +
 
1179
                                     (2*global_ddl_log.name_len)]));
 
1180
  if (write_ddl_log_file_entry((uchar*) file_entry_buf,
 
1181
                               (*active_entry)->entry_pos, IO_SIZE))
1181
1182
  {
1182
1183
    error= TRUE;
1183
1184
    sql_print_error("Failed to write entry_no = %u",
1227
1228
                                 DDL_LOG_MEMORY_ENTRY **active_entry)
1228
1229
{
1229
1230
  bool write_header= FALSE;
1230
 
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
 
1231
  char file_entry_buf[IO_SIZE];
1231
1232
  DBUG_ENTER("write_execute_ddl_log_entry");
1232
1233
 
1233
1234
  if (init_ddl_log())
1234
1235
  {
1235
1236
    DBUG_RETURN(TRUE);
1236
1237
  }
 
1238
  memset(file_entry_buf, 0, sizeof(file_entry_buf));
1237
1239
  if (!complete)
1238
1240
  {
1239
1241
    /*
1247
1249
  }
1248
1250
  else
1249
1251
    file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= (char)DDL_IGNORE_LOG_ENTRY_CODE;
1250
 
  file_entry_buf[DDL_LOG_ACTION_TYPE_POS]= 0; /* Ignored for execute entries */
1251
 
  file_entry_buf[DDL_LOG_PHASE_POS]= 0;
1252
1252
  int4store(&file_entry_buf[DDL_LOG_NEXT_ENTRY_POS], first_entry);
1253
 
  file_entry_buf[DDL_LOG_NAME_POS]= 0;
1254
 
  file_entry_buf[DDL_LOG_NAME_POS + FN_LEN]= 0;
1255
 
  file_entry_buf[DDL_LOG_NAME_POS + 2*FN_LEN]= 0;
1256
1253
  if (!(*active_entry))
1257
1254
  {
1258
1255
    if (get_free_ddl_log_entry(active_entry, &write_header))
1260
1257
      DBUG_RETURN(TRUE);
1261
1258
    }
1262
1259
  }
1263
 
  if (write_ddl_log_file_entry((*active_entry)->entry_pos))
 
1260
  if (write_ddl_log_file_entry((uchar*) file_entry_buf,
 
1261
                               (*active_entry)->entry_pos,
 
1262
                               IO_SIZE))
1264
1263
  {
1265
1264
    sql_print_error("Error writing execute entry in ddl log");
1266
1265
    release_ddl_log_memory_entry(*active_entry);
1305
1304
 
1306
1305
bool deactivate_ddl_log_entry(uint entry_no)
1307
1306
{
1308
 
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
 
1307
  uchar file_entry_buf[DDL_LOG_NAME_POS];
1309
1308
  DBUG_ENTER("deactivate_ddl_log_entry");
1310
1309
 
1311
 
  if (!read_ddl_log_file_entry(entry_no))
 
1310
 
 
1311
  /*
 
1312
    Only need to read and write the first bytes of the entry, where
 
1313
    ENTRY_TYPE, ACTION_TYPE and PHASE reside. Using DDL_LOG_NAME_POS
 
1314
    to include all info except for the names.
 
1315
  */
 
1316
  if (!read_ddl_log_file_entry(file_entry_buf, entry_no, DDL_LOG_NAME_POS))
1312
1317
  {
1313
1318
    if (file_entry_buf[DDL_LOG_ENTRY_TYPE_POS] == DDL_LOG_ENTRY_CODE)
1314
1319
    {
1326
1331
      {
1327
1332
        DBUG_ASSERT(0);
1328
1333
      }
1329
 
      if (write_ddl_log_file_entry(entry_no))
 
1334
      if (write_ddl_log_file_entry(file_entry_buf, entry_no, DDL_LOG_NAME_POS))
1330
1335
      {
1331
1336
        sql_print_error("Error in deactivating log entry. Position = %u",
1332
1337
                        entry_no);
1387
1392
  DDL_LOG_MEMORY_ENTRY *next_log_entry= log_entry->next_log_entry;
1388
1393
  DDL_LOG_MEMORY_ENTRY *prev_log_entry= log_entry->prev_log_entry;
1389
1394
  DBUG_ENTER("release_ddl_log_memory_entry");
 
1395
  mysql_mutex_assert_owner(&LOCK_gdl);
1390
1396
 
1391
1397
  global_ddl_log.first_free= log_entry;
1392
1398
  log_entry->next_log_entry= first_free;
1416
1422
{
1417
1423
  DDL_LOG_ENTRY ddl_log_entry;
1418
1424
  uint read_entry= first_entry;
 
1425
  uchar file_entry_buf[IO_SIZE];
1419
1426
  DBUG_ENTER("execute_ddl_log_entry");
1420
1427
 
1421
1428
  mysql_mutex_lock(&LOCK_gdl);
1422
1429
  do
1423
1430
  {
1424
 
    if (read_ddl_log_entry(read_entry, &ddl_log_entry))
 
1431
    if (read_ddl_log_file_entry(file_entry_buf, read_entry, IO_SIZE))
1425
1432
    {
1426
 
      /* Write to error log and continue with next log entry */
 
1433
      /* Print the error to the log and continue with next log entry */
1427
1434
      sql_print_error("Failed to read entry = %u from ddl log",
1428
1435
                      read_entry);
1429
1436
      break;
1430
1437
    }
 
1438
    set_ddl_log_entry_from_buf(read_entry, file_entry_buf, &ddl_log_entry);
1431
1439
    DBUG_ASSERT(ddl_log_entry.entry_type == DDL_LOG_ENTRY_CODE ||
1432
1440
                ddl_log_entry.entry_type == DDL_IGNORE_LOG_ENTRY_CODE);
1433
1441
 
1434
1442
    if (execute_ddl_log_action(thd, &ddl_log_entry))
1435
1443
    {
1436
 
      /* Write to error log and continue with next log entry */
 
1444
      /* Print the error to the log and continue with next log entry */
1437
1445
      sql_print_error("Failed to execute action for entry = %u from ddl log",
1438
1446
                      read_entry);
1439
1447
      break;
1478
1486
  uint num_entries, i;
1479
1487
  THD *thd;
1480
1488
  DDL_LOG_ENTRY ddl_log_entry;
 
1489
  uchar *file_entry_buf;
 
1490
  uint io_size;
1481
1491
  char file_name[FN_REFLEN];
1482
1492
  DBUG_ENTER("execute_ddl_log_recovery");
1483
1493
 
1484
1494
  /*
1485
1495
    Initialise global_ddl_log struct
1486
1496
  */
1487
 
  bzero(global_ddl_log.file_entry_buf, sizeof(global_ddl_log.file_entry_buf));
1488
1497
  global_ddl_log.inited= FALSE;
1489
1498
  global_ddl_log.recovery_phase= TRUE;
1490
1499
  global_ddl_log.io_size= IO_SIZE;
1499
1508
  thd->store_globals();
1500
1509
 
1501
1510
  num_entries= read_ddl_log_header();
 
1511
  io_size= global_ddl_log.io_size;
 
1512
  file_entry_buf= (uchar*) my_malloc(io_size, MYF(0));
 
1513
  if (!file_entry_buf)
 
1514
  {
 
1515
    sql_print_error("Failed to allocate buffer for recover ddl log");
 
1516
    DBUG_VOID_RETURN;
 
1517
  }
1502
1518
  for (i= 1; i < num_entries + 1; i++)
1503
1519
  {
1504
 
    if (read_ddl_log_entry(i, &ddl_log_entry))
 
1520
    if (read_ddl_log_file_entry(file_entry_buf, i, io_size))
1505
1521
    {
1506
1522
      sql_print_error("Failed to read entry no = %u from ddl log",
1507
1523
                       i);
1508
1524
      continue;
1509
1525
    }
 
1526
 
 
1527
    set_ddl_log_entry_from_buf(i, file_entry_buf, &ddl_log_entry);
1510
1528
    if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE)
1511
1529
    {
1512
1530
      if (execute_ddl_log_entry(thd, ddl_log_entry.next_entry))
1521
1539
  (void) mysql_file_delete(key_file_global_ddl_log, file_name, MYF(0));
1522
1540
  global_ddl_log.recovery_phase= FALSE;
1523
1541
  delete thd;
 
1542
  my_free(file_entry_buf);
1524
1543
  /* Remember that we don't have a THD */
1525
1544
  my_pthread_setspecific_ptr(THR_THD,  0);
1526
1545
  DBUG_VOID_RETURN;
1537
1556
 
1538
1557
void release_ddl_log()
1539
1558
{
1540
 
  DDL_LOG_MEMORY_ENTRY *free_list= global_ddl_log.first_free;
1541
 
  DDL_LOG_MEMORY_ENTRY *used_list= global_ddl_log.first_used;
 
1559
  DDL_LOG_MEMORY_ENTRY *free_list;
 
1560
  DDL_LOG_MEMORY_ENTRY *used_list;
1542
1561
  DBUG_ENTER("release_ddl_log");
1543
1562
 
1544
1563
  if (!global_ddl_log.do_release)
1545
1564
    DBUG_VOID_RETURN;
1546
1565
 
1547
1566
  mysql_mutex_lock(&LOCK_gdl);
 
1567
  free_list= global_ddl_log.first_free;
 
1568
  used_list= global_ddl_log.first_used;
1548
1569
  while (used_list)
1549
1570
  {
1550
1571
    DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry;
1673
1694
                                                         &syntax_len,
1674
1695
                                                         TRUE, TRUE,
1675
1696
                                                         lpt->create_info,
1676
 
                                                         lpt->alter_info)))
 
1697
                                                         lpt->alter_info,
 
1698
                                                         NULL)))
1677
1699
        {
1678
1700
          DBUG_RETURN(TRUE);
1679
1701
        }
1766
1788
                                                       &syntax_len,
1767
1789
                                                       TRUE, TRUE,
1768
1790
                                                       lpt->create_info,
1769
 
                                                       lpt->alter_info)))
 
1791
                                                       lpt->alter_info,
 
1792
                                                       NULL)))
1770
1793
      {
1771
1794
        error= 1;
1772
1795
        goto err;
4061
4084
                                                     &syntax_len,
4062
4085
                                                     TRUE, TRUE,
4063
4086
                                                     create_info,
4064
 
                                                     alter_info)))
 
4087
                                                     alter_info,
 
4088
                                                     NULL)))
4065
4089
      goto err;
4066
4090
    part_info->part_info_string= part_syntax_buf;
4067
4091
    part_info->part_info_len= syntax_len;