~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_table.cc

  • Committer: brian
  • Date: 2008-07-03 13:40:21 UTC
  • Revision ID: brian@localhost.localdomain-20080703134021-7p4ab3xpjpmbcebi
Update for using real bool types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
    read_ddl_log_file_entry()
322
322
    entry_no                     Entry number to read
323
323
  RETURN VALUES
324
 
    TRUE                         Error
325
 
    FALSE                        Success
 
324
    true                         Error
 
325
    false                        Success
326
326
*/
327
327
 
328
328
static bool read_ddl_log_file_entry(uint entry_no)
329
329
{
330
 
  bool error= FALSE;
 
330
  bool error= false;
331
331
  File file_id= global_ddl_log.file_id;
332
332
  uchar *file_entry_buf= (uchar*)global_ddl_log.file_entry_buf;
333
 
  uint io_size= global_ddl_log.io_size;
 
333
  ssize_t io_size= (ssize_t)global_ddl_log.io_size;
334
334
  DBUG_ENTER("read_ddl_log_file_entry");
335
335
 
336
336
  if (pread(file_id, file_entry_buf, io_size, io_size * entry_no) != io_size)
337
 
    error= TRUE;
 
337
    error= true;
338
338
  DBUG_RETURN(error);
339
339
}
340
340
 
345
345
    write_ddl_log_file_entry()
346
346
    entry_no                     Entry number to read
347
347
  RETURN VALUES
348
 
    TRUE                         Error
349
 
    FALSE                        Success
 
348
    true                         Error
 
349
    false                        Success
350
350
*/
351
351
 
352
352
static bool write_ddl_log_file_entry(uint entry_no)
353
353
{
354
 
  bool error= FALSE;
 
354
  bool error= false;
355
355
  File file_id= global_ddl_log.file_id;
356
356
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
357
357
  DBUG_ENTER("write_ddl_log_file_entry");
358
358
 
359
359
  if (pwrite(file_id, (uchar*)file_entry_buf,
360
360
             IO_SIZE, IO_SIZE * entry_no) != IO_SIZE)
361
 
    error= TRUE;
 
361
    error= true;
362
362
  DBUG_RETURN(error);
363
363
}
364
364
 
368
368
  SYNOPSIS
369
369
    write_ddl_log_header()
370
370
  RETURN VALUES
371
 
    TRUE                      Error
372
 
    FALSE                     Success
 
371
    true                      Error
 
372
    false                     Success
373
373
*/
374
374
 
375
375
static bool write_ddl_log_header()
376
376
{
377
377
  uint16 const_var;
378
 
  bool error= FALSE;
 
378
  bool error= false;
379
379
  DBUG_ENTER("write_ddl_log_header");
380
380
 
381
381
  int4store(&global_ddl_log.file_entry_buf[DDL_LOG_NUM_ENTRY_POS],
389
389
  if (write_ddl_log_file_entry(0UL))
390
390
  {
391
391
    sql_print_error("Error writing ddl log header");
392
 
    DBUG_RETURN(TRUE);
 
392
    DBUG_RETURN(true);
393
393
  }
394
394
  VOID(sync_ddl_log());
395
395
  DBUG_RETURN(error);
429
429
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
430
430
  char file_name[FN_REFLEN];
431
431
  uint entry_no;
432
 
  bool successful_open= FALSE;
 
432
  bool successful_open= false;
433
433
  DBUG_ENTER("read_ddl_log_header");
434
434
 
435
435
  create_ddl_log_file_name(file_name);
442
442
      sql_print_error("Failed to read ddl log file in recovery");
443
443
    }
444
444
    else
445
 
      successful_open= TRUE;
 
445
      successful_open= true;
446
446
  }
447
447
  entry_no= uint4korr(&file_entry_buf[DDL_LOG_NUM_ENTRY_POS]);
448
448
  global_ddl_log.name_len= uint4korr(&file_entry_buf[DDL_LOG_NAME_LEN_POS]);
472
472
    read_entry               Number of entry to read
473
473
    out:entry_info           Information from entry
474
474
  RETURN VALUES
475
 
    TRUE                     Error
476
 
    FALSE                    Success
 
475
    true                     Error
 
476
    false                    Success
477
477
  DESCRIPTION
478
478
    Read a specified entry in the ddl log
479
479
*/
487
487
 
488
488
  if (read_ddl_log_file_entry(read_entry))
489
489
  {
490
 
    DBUG_RETURN(TRUE);
 
490
    DBUG_RETURN(true);
491
491
  }
492
492
  ddl_log_entry->entry_pos= read_entry;
493
493
  single_char= file_entry_buf[DDL_LOG_ENTRY_TYPE_POS];
501
501
  ddl_log_entry->from_name= &file_entry_buf[inx];
502
502
  inx+= global_ddl_log.name_len;
503
503
  ddl_log_entry->handler_name= &file_entry_buf[inx];
504
 
  DBUG_RETURN(FALSE);
 
504
  DBUG_RETURN(false);
505
505
}
506
506
 
507
507
 
515
515
    number of entries to zero.
516
516
 
517
517
  RETURN VALUES
518
 
    TRUE                     Error
519
 
    FALSE                    Success
 
518
    true                     Error
 
519
    false                    Success
520
520
*/
521
521
 
522
522
static bool init_ddl_log()
536
536
  {
537
537
    /* Couldn't create ddl log file, this is serious error */
538
538
    sql_print_error("Failed to open ddl log file");
539
 
    DBUG_RETURN(TRUE);
 
539
    DBUG_RETURN(true);
540
540
  }
541
 
  global_ddl_log.inited= TRUE;
 
541
  global_ddl_log.inited= true;
542
542
  if (write_ddl_log_header())
543
543
  {
544
544
    VOID(my_close(global_ddl_log.file_id, MYF(MY_WME)));
545
 
    global_ddl_log.inited= FALSE;
546
 
    DBUG_RETURN(TRUE);
 
545
    global_ddl_log.inited= false;
 
546
    DBUG_RETURN(true);
547
547
  }
548
548
 
549
549
end:
550
 
  DBUG_RETURN(FALSE);
 
550
  DBUG_RETURN(false);
551
551
}
552
552
 
553
553
 
557
557
    execute_ddl_log_action()
558
558
    ddl_log_entry              Information in action entry to execute
559
559
  RETURN VALUES
560
 
    TRUE                       Error
561
 
    FALSE                      Success
 
560
    true                       Error
 
561
    false                      Success
562
562
*/
563
563
 
564
564
static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
565
565
{
566
 
  bool frm_action= FALSE;
 
566
  bool frm_action= false;
567
567
  LEX_STRING handler_name;
568
568
  handler *file= NULL;
569
569
  MEM_ROOT mem_root;
570
 
  int error= TRUE;
 
570
  int error= true;
571
571
  char to_path[FN_REFLEN];
572
572
  char from_path[FN_REFLEN];
573
573
  handlerton *hton;
575
575
 
576
576
  if (ddl_log_entry->entry_type == DDL_IGNORE_LOG_ENTRY_CODE)
577
577
  {
578
 
    DBUG_RETURN(FALSE);
 
578
    DBUG_RETURN(false);
579
579
  }
580
580
  handler_name.str= (char*)ddl_log_entry->handler_name;
581
581
  handler_name.length= strlen(ddl_log_entry->handler_name);
582
582
  init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); 
583
583
  if (!strcmp(ddl_log_entry->handler_name, reg_ext))
584
 
    frm_action= TRUE;
 
584
    frm_action= true;
585
585
  else
586
586
  {
587
587
    plugin_ref plugin= ha_resolve_by_name(thd, &handler_name);
625
625
        if ((deactivate_ddl_log_entry(ddl_log_entry->entry_pos)))
626
626
          break;
627
627
        VOID(sync_ddl_log());
628
 
        error= FALSE;
 
628
        error= false;
629
629
        if (ddl_log_entry->action_type == DDL_LOG_DELETE_ACTION)
630
630
          break;
631
631
      }
638
638
    }
639
639
    case DDL_LOG_RENAME_ACTION:
640
640
    {
641
 
      error= TRUE;
 
641
      error= true;
642
642
      if (frm_action)
643
643
      {
644
644
        strxmov(to_path, ddl_log_entry->name, reg_ext, NullS);
655
655
      if ((deactivate_ddl_log_entry(ddl_log_entry->entry_pos)))
656
656
        break;
657
657
      VOID(sync_ddl_log());
658
 
      error= FALSE;
 
658
      error= false;
659
659
      break;
660
660
    }
661
661
    default:
675
675
    get_free_ddl_log_entry()
676
676
    out:active_entry                A ddl log memory entry returned
677
677
  RETURN VALUES
678
 
    TRUE                       Error
679
 
    FALSE                      Success
 
678
    true                       Error
 
679
    false                      Success
680
680
*/
681
681
 
682
682
static bool get_free_ddl_log_entry(DDL_LOG_MEMORY_ENTRY **active_entry,
692
692
                              sizeof(DDL_LOG_MEMORY_ENTRY), MYF(MY_WME))))
693
693
    {
694
694
      sql_print_error("Failed to allocate memory for ddl log free list");
695
 
      DBUG_RETURN(TRUE);
 
695
      DBUG_RETURN(true);
696
696
    }
697
697
    global_ddl_log.num_entries++;
698
698
    used_entry->entry_pos= global_ddl_log.num_entries;
699
 
    *write_header= TRUE;
 
699
    *write_header= true;
700
700
  }
701
701
  else
702
702
  {
703
703
    used_entry= global_ddl_log.first_free;
704
704
    global_ddl_log.first_free= used_entry->next_log_entry;
705
 
    *write_header= FALSE;
 
705
    *write_header= false;
706
706
  }
707
707
  /*
708
708
    Move from free list to used list
714
714
    first_used->prev_log_entry= used_entry;
715
715
 
716
716
  *active_entry= used_entry;
717
 
  DBUG_RETURN(FALSE);
 
717
  DBUG_RETURN(false);
718
718
}
719
719
 
720
720
 
730
730
    out:entry_written     Entry information written into   
731
731
 
732
732
  RETURN VALUES
733
 
    TRUE                      Error
734
 
    FALSE                     Success
 
733
    true                      Error
 
734
    false                     Success
735
735
 
736
736
  DESCRIPTION
737
737
    A careful write of the ddl log is performed to ensure that we can
746
746
 
747
747
  if (init_ddl_log())
748
748
  {
749
 
    DBUG_RETURN(TRUE);
 
749
    DBUG_RETURN(true);
750
750
  }
751
751
  global_ddl_log.file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]=
752
752
                                    (char)DDL_LOG_ENTRY_CODE;
772
772
          ddl_log_entry->handler_name, FN_LEN - 1);
773
773
  if (get_free_ddl_log_entry(active_entry, &write_header))
774
774
  {
775
 
    DBUG_RETURN(TRUE);
 
775
    DBUG_RETURN(true);
776
776
  }
777
 
  error= FALSE;
 
777
  error= false;
778
778
  if (write_ddl_log_file_entry((*active_entry)->entry_pos))
779
779
  {
780
 
    error= TRUE;
 
780
    error= true;
781
781
    sql_print_error("Failed to write entry_no = %u",
782
782
                    (*active_entry)->entry_pos);
783
783
  }
785
785
  {
786
786
    VOID(sync_ddl_log());
787
787
    if (write_ddl_log_header())
788
 
      error= TRUE;
 
788
      error= true;
789
789
  }
790
790
  if (error)
791
791
    release_ddl_log_memory_entry(*active_entry);
808
808
                                   returned. In this case the entry written
809
809
                                   is returned in this parameter
810
810
  RETURN VALUES
811
 
    TRUE                           Error
812
 
    FALSE                          Success
 
811
    true                           Error
 
812
    false                          Success
813
813
 
814
814
  DESCRIPTION
815
815
    This is the last write in the ddl log. The previous log entries have
824
824
                                 bool complete,
825
825
                                 DDL_LOG_MEMORY_ENTRY **active_entry)
826
826
{
827
 
  bool write_header= FALSE;
 
827
  bool write_header= false;
828
828
  char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
829
829
  DBUG_ENTER("write_execute_ddl_log_entry");
830
830
 
831
831
  if (init_ddl_log())
832
832
  {
833
 
    DBUG_RETURN(TRUE);
 
833
    DBUG_RETURN(true);
834
834
  }
835
835
  if (!complete)
836
836
  {
855
855
  {
856
856
    if (get_free_ddl_log_entry(active_entry, &write_header))
857
857
    {
858
 
      DBUG_RETURN(TRUE);
 
858
      DBUG_RETURN(true);
859
859
    }
860
860
  }
861
861
  if (write_ddl_log_file_entry((*active_entry)->entry_pos))
862
862
  {
863
863
    sql_print_error("Error writing execute entry in ddl log");
864
864
    release_ddl_log_memory_entry(*active_entry);
865
 
    DBUG_RETURN(TRUE);
 
865
    DBUG_RETURN(true);
866
866
  }
867
867
  VOID(sync_ddl_log());
868
868
  if (write_header)
870
870
    if (write_ddl_log_header())
871
871
    {
872
872
      release_ddl_log_memory_entry(*active_entry);
873
 
      DBUG_RETURN(TRUE);
 
873
      DBUG_RETURN(true);
874
874
    }
875
875
  }
876
 
  DBUG_RETURN(FALSE);
 
876
  DBUG_RETURN(false);
877
877
}
878
878
 
879
879
 
883
883
    deactivate_ddl_log_entry()
884
884
    entry_no                      Entry position of record to change
885
885
  RETURN VALUES
886
 
    TRUE                         Error
887
 
    FALSE                        Success
 
886
    true                         Error
 
887
    false                        Success
888
888
  DESCRIPTION
889
889
    During replace operations where we start with an existing table called
890
890
    t1 and a replacement table called t1#temp or something else and where
928
928
      {
929
929
        sql_print_error("Error in deactivating log entry. Position = %u",
930
930
                        entry_no);
931
 
        DBUG_RETURN(TRUE);
 
931
        DBUG_RETURN(true);
932
932
      }
933
933
    }
934
934
  }
935
935
  else
936
936
  {
937
937
    sql_print_error("Failed in reading entry before deactivating it");
938
 
    DBUG_RETURN(TRUE);
 
938
    DBUG_RETURN(true);
939
939
  }
940
 
  DBUG_RETURN(FALSE);
 
940
  DBUG_RETURN(false);
941
941
}
942
942
 
943
943
 
946
946
  SYNOPSIS
947
947
    sync_ddl_log()
948
948
  RETURN VALUES
949
 
    TRUE                      Error
950
 
    FALSE                     Success
 
949
    true                      Error
 
950
    false                     Success
951
951
*/
952
952
 
953
953
bool sync_ddl_log()
954
954
{
955
 
  bool error= FALSE;
 
955
  bool error= false;
956
956
  DBUG_ENTER("sync_ddl_log");
957
957
 
958
958
  if ((!global_ddl_log.recovery_phase) &&
959
959
      init_ddl_log())
960
960
  {
961
 
    DBUG_RETURN(TRUE);
 
961
    DBUG_RETURN(true);
962
962
  }
963
963
  if (my_sync(global_ddl_log.file_id, MYF(0)))
964
964
  {
965
965
    /* Write to error log */
966
966
    sql_print_error("Failed to sync ddl log");
967
 
    error= TRUE;
 
967
    error= true;
968
968
  }
969
969
  DBUG_RETURN(error);
970
970
}
1006
1006
    execute_ddl_log_entry()
1007
1007
    first_entry                Reference to first action in entry
1008
1008
  RETURN VALUES
1009
 
    TRUE                       Error
1010
 
    FALSE                      Success
 
1009
    true                       Error
 
1010
    false                      Success
1011
1011
*/
1012
1012
 
1013
1013
bool execute_ddl_log_entry(THD *thd, uint first_entry)
1039
1039
    read_entry= ddl_log_entry.next_entry;
1040
1040
  } while (read_entry);
1041
1041
  pthread_mutex_unlock(&LOCK_gdl);
1042
 
  DBUG_RETURN(FALSE);
 
1042
  DBUG_RETURN(false);
1043
1043
}
1044
1044
 
1045
1045
 
1083
1083
    Initialise global_ddl_log struct
1084
1084
  */
1085
1085
  bzero(global_ddl_log.file_entry_buf, sizeof(global_ddl_log.file_entry_buf));
1086
 
  global_ddl_log.inited= FALSE;
1087
 
  global_ddl_log.recovery_phase= TRUE;
 
1086
  global_ddl_log.inited= false;
 
1087
  global_ddl_log.recovery_phase= true;
1088
1088
  global_ddl_log.io_size= IO_SIZE;
1089
1089
  global_ddl_log.file_id= (File) -1;
1090
1090
 
1117
1117
  close_ddl_log();
1118
1118
  create_ddl_log_file_name(file_name);
1119
1119
  VOID(my_delete(file_name, MYF(0)));
1120
 
  global_ddl_log.recovery_phase= FALSE;
 
1120
  global_ddl_log.recovery_phase= false;
1121
1121
  delete thd;
1122
1122
  /* Remember that we don't have a THD */
1123
1123
  my_pthread_setspecific_ptr(THR_THD,  0);
1198
1198
    if (clear_error)
1199
1199
      thd->clear_error();
1200
1200
    thd->binlog_query(THD::STMT_QUERY_TYPE,
1201
 
                      query, query_length, FALSE, FALSE);
 
1201
                      query, query_length, false, false);
1202
1202
  }
1203
1203
}
1204
1204
 
1222
1222
    not if under LOCK TABLES.
1223
1223
 
1224
1224
  RETURN
1225
 
    FALSE OK.  In this case ok packet is sent to user
1226
 
    TRUE  Error
 
1225
    false OK.  In this case ok packet is sent to user
 
1226
    true  Error
1227
1227
 
1228
1228
*/
1229
1229
 
1230
1230
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
1231
1231
                    my_bool drop_temporary)
1232
1232
{
1233
 
  bool error, need_start_waiting= FALSE;
 
1233
  bool error, need_start_waiting= false;
1234
1234
  DBUG_ENTER("mysql_rm_table");
1235
1235
 
1236
1236
  if (tables && tables->schema_table)
1237
1237
  {
1238
1238
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.str);
1239
 
    DBUG_RETURN(TRUE);
 
1239
    DBUG_RETURN(true);
1240
1240
  }
1241
1241
 
1242
1242
  /* mark for close and remove all cached entries */
1245
1245
  {
1246
1246
    if (!thd->locked_tables &&
1247
1247
        !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
1248
 
      DBUG_RETURN(TRUE);
 
1248
      DBUG_RETURN(true);
1249
1249
  }
1250
1250
 
1251
1251
  /*
1259
1259
    start_waiting_global_read_lock(thd);
1260
1260
 
1261
1261
  if (error)
1262
 
    DBUG_RETURN(TRUE);
 
1262
    DBUG_RETURN(true);
1263
1263
  my_ok(thd);
1264
 
  DBUG_RETURN(FALSE);
 
1264
  DBUG_RETURN(false);
1265
1265
}
1266
1266
 
1267
1267
/*
1317
1317
      built_query.append("DROP TABLE ");
1318
1318
  }
1319
1319
 
1320
 
  mysql_ha_rm_tables(thd, tables, FALSE);
 
1320
  mysql_ha_rm_tables(thd, tables, false);
1321
1321
 
1322
1322
  pthread_mutex_lock(&LOCK_open);
1323
1323
 
1879
1879
    sets create_info->varchar if the table has a varchar
1880
1880
 
1881
1881
  RETURN VALUES
1882
 
    FALSE    OK
1883
 
    TRUE     error
 
1882
    false    OK
 
1883
    true     error
1884
1884
*/
1885
1885
 
1886
1886
static int
1940
1940
      strmake(strmake(tmp, save_cs->csname, sizeof(tmp)-4),
1941
1941
              STRING_WITH_LEN("_bin"));
1942
1942
      my_error(ER_UNKNOWN_COLLATION, MYF(0), tmp);
1943
 
      DBUG_RETURN(TRUE);
 
1943
      DBUG_RETURN(true);
1944
1944
    }
1945
1945
 
1946
1946
    /*
1970
1970
      {
1971
1971
        /* Could not convert */
1972
1972
        my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
1973
 
        DBUG_RETURN(TRUE);
 
1973
        DBUG_RETURN(true);
1974
1974
      }
1975
1975
    }
1976
1976
 
2027
2027
                                comma_buf, comma_length, NULL, 0))
2028
2028
            {
2029
2029
              my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", tmp->ptr());
2030
 
              DBUG_RETURN(TRUE);
 
2030
              DBUG_RETURN(true);
2031
2031
            }
2032
2032
          }
2033
2033
        }
2048
2048
            if ((sql_field->flags & NOT_NULL_FLAG) != 0)
2049
2049
            {
2050
2050
              my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
2051
 
              DBUG_RETURN(TRUE);
 
2051
              DBUG_RETURN(true);
2052
2052
            }
2053
2053
 
2054
2054
            /* else, NULL is an allowed value */
2064
2064
          if (not_found)
2065
2065
          {
2066
2066
            my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
2067
 
            DBUG_RETURN(TRUE);
 
2067
            DBUG_RETURN(true);
2068
2068
          }
2069
2069
        }
2070
2070
        calculate_interval_lengths(cs, interval, &dummy, &field_length);
2082
2082
            if ((sql_field->flags & NOT_NULL_FLAG) != 0)
2083
2083
            {
2084
2084
              my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
2085
 
              DBUG_RETURN(TRUE);
 
2085
              DBUG_RETURN(true);
2086
2086
            }
2087
2087
 
2088
2088
            /* else, the defaults yield the correct length for NULLs. */
2093
2093
            if (find_type2(interval, def->ptr(), def->length(), cs) == 0) /* not found */
2094
2094
            {
2095
2095
              my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
2096
 
              DBUG_RETURN(TRUE);
 
2096
              DBUG_RETURN(true);
2097
2097
            }
2098
2098
          }
2099
2099
        }
2114
2114
 
2115
2115
    sql_field->create_length_to_internal_length();
2116
2116
    if (prepare_blob_field(thd, sql_field))
2117
 
      DBUG_RETURN(TRUE);
 
2117
      DBUG_RETURN(true);
2118
2118
 
2119
2119
    if (!(sql_field->flags & NOT_NULL_FLAG))
2120
2120
      null_fields++;
2122
2122
    if (check_column_name(sql_field->field_name))
2123
2123
    {
2124
2124
      my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
2125
 
      DBUG_RETURN(TRUE);
 
2125
      DBUG_RETURN(true);
2126
2126
    }
2127
2127
 
2128
2128
    /* Check if we have used the same field name before */
2139
2139
        if (field_no < select_field_pos || dup_no >= select_field_pos)
2140
2140
        {
2141
2141
          my_error(ER_DUP_FIELDNAME, MYF(0), sql_field->field_name);
2142
 
          DBUG_RETURN(TRUE);
 
2142
          DBUG_RETURN(true);
2143
2143
        }
2144
2144
        else
2145
2145
        {
2189
2189
    if (prepare_create_field(sql_field, &blob_columns, 
2190
2190
                             &timestamps, &timestamps_with_niladic,
2191
2191
                             file->ha_table_flags()))
2192
 
      DBUG_RETURN(TRUE);
 
2192
      DBUG_RETURN(true);
2193
2193
    if (sql_field->sql_type == MYSQL_TYPE_VARCHAR)
2194
 
      create_info->varchar= TRUE;
 
2194
      create_info->varchar= true;
2195
2195
    sql_field->offset= record_offset;
2196
2196
    if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
2197
2197
      auto_increment++;
2201
2201
  {
2202
2202
    my_message(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,
2203
2203
               ER(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS), MYF(0));
2204
 
    DBUG_RETURN(TRUE);
 
2204
    DBUG_RETURN(true);
2205
2205
  }
2206
2206
  if (auto_increment > 1)
2207
2207
  {
2208
2208
    my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
2209
 
    DBUG_RETURN(TRUE);
 
2209
    DBUG_RETURN(true);
2210
2210
  }
2211
2211
  if (auto_increment &&
2212
2212
      (file->ha_table_flags() & HA_NO_AUTO_INCREMENT))
2213
2213
  {
2214
2214
    my_message(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,
2215
2215
               ER(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT), MYF(0));
2216
 
    DBUG_RETURN(TRUE);
 
2216
    DBUG_RETURN(true);
2217
2217
  }
2218
2218
 
2219
2219
  if (blob_columns && (file->ha_table_flags() & HA_NO_BLOBS))
2220
2220
  {
2221
2221
    my_message(ER_TABLE_CANT_HANDLE_BLOB, ER(ER_TABLE_CANT_HANDLE_BLOB),
2222
2222
               MYF(0));
2223
 
    DBUG_RETURN(TRUE);
 
2223
    DBUG_RETURN(true);
2224
2224
  }
2225
2225
 
2226
2226
  /* Create keys */
2252
2252
                 (fk_key->name.str ? fk_key->name.str :
2253
2253
                                     "foreign key without name"),
2254
2254
                 ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
2255
 
        DBUG_RETURN(TRUE);
 
2255
        DBUG_RETURN(true);
2256
2256
      }
2257
2257
      continue;
2258
2258
    }
2261
2261
    if (key->columns.elements > tmp)
2262
2262
    {
2263
2263
      my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp);
2264
 
      DBUG_RETURN(TRUE);
 
2264
      DBUG_RETURN(true);
2265
2265
    }
2266
2266
    if (check_identifier_name(&key->name, ER_TOO_LONG_IDENT))
2267
 
      DBUG_RETURN(TRUE);
 
2267
      DBUG_RETURN(true);
2268
2268
    key_iterator2.rewind ();
2269
2269
    if (key->type != Key::FOREIGN_KEY)
2270
2270
    {
2303
2303
        !my_strcasecmp(system_charset_info,key->name.str, primary_key_name))
2304
2304
    {
2305
2305
      my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str);
2306
 
      DBUG_RETURN(TRUE);
 
2306
      DBUG_RETURN(true);
2307
2307
    }
2308
2308
  }
2309
2309
  tmp=file->max_keys();
2310
2310
  if (*key_count > tmp)
2311
2311
  {
2312
2312
    my_error(ER_TOO_MANY_KEYS,MYF(0),tmp);
2313
 
    DBUG_RETURN(TRUE);
 
2313
    DBUG_RETURN(true);
2314
2314
  }
2315
2315
 
2316
2316
  (*key_info_buffer)= key_info= (KEY*) sql_calloc(sizeof(KEY) * (*key_count));
2317
2317
  key_part_info=(KEY_PART_INFO*) sql_calloc(sizeof(KEY_PART_INFO)*key_parts);
2318
2318
  if (!*key_info_buffer || ! key_part_info)
2319
 
    DBUG_RETURN(TRUE);                          // Out of memory
 
2319
    DBUG_RETURN(true);                          // Out of memory
2320
2320
 
2321
2321
  key_iterator.rewind();
2322
2322
  key_number=0;
2403
2403
      if (!sql_field)
2404
2404
      {
2405
2405
        my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
2406
 
        DBUG_RETURN(TRUE);
 
2406
        DBUG_RETURN(true);
2407
2407
      }
2408
2408
      while ((dup_column= cols2++) != column)
2409
2409
      {
2413
2413
          my_printf_error(ER_DUP_FIELDNAME,
2414
2414
                          ER(ER_DUP_FIELDNAME),MYF(0),
2415
2415
                          column->field_name.str);
2416
 
          DBUG_RETURN(TRUE);
 
2416
          DBUG_RETURN(true);
2417
2417
        }
2418
2418
      }
2419
2419
      cols2.rewind();
2425
2425
          if (!(file->ha_table_flags() & HA_CAN_INDEX_BLOBS))
2426
2426
          {
2427
2427
            my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str);
2428
 
            DBUG_RETURN(TRUE);
 
2428
            DBUG_RETURN(true);
2429
2429
          }
2430
2430
          if (!column->length)
2431
2431
          {
2432
2432
            my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
2433
 
            DBUG_RETURN(TRUE);
 
2433
            DBUG_RETURN(true);
2434
2434
          }
2435
2435
        }
2436
2436
        if (!(sql_field->flags & NOT_NULL_FLAG))
2448
2448
            if (!(file->ha_table_flags() & HA_NULL_IN_KEY))
2449
2449
            {
2450
2450
              my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str);
2451
 
              DBUG_RETURN(TRUE);
 
2451
              DBUG_RETURN(true);
2452
2452
            }
2453
2453
          }
2454
2454
        }
2486
2486
            else
2487
2487
            {
2488
2488
              my_error(ER_TOO_LONG_KEY,MYF(0),length);
2489
 
              DBUG_RETURN(TRUE);
 
2489
              DBUG_RETURN(true);
2490
2490
            }
2491
2491
          }
2492
2492
        }
2498
2498
                    column->length != length)))
2499
2499
        {
2500
2500
          my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
2501
 
          DBUG_RETURN(TRUE);
 
2501
          DBUG_RETURN(true);
2502
2502
        }
2503
2503
        else if (!(file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS))
2504
2504
          length=column->length;
2506
2506
      else if (length == 0)
2507
2507
      {
2508
2508
        my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name.str);
2509
 
          DBUG_RETURN(TRUE);
 
2509
          DBUG_RETURN(true);
2510
2510
      }
2511
2511
      if (length > file->max_key_part_length())
2512
2512
      {
2525
2525
        else
2526
2526
        {
2527
2527
          my_error(ER_TOO_LONG_KEY,MYF(0),length);
2528
 
          DBUG_RETURN(TRUE);
 
2528
          DBUG_RETURN(true);
2529
2529
        }
2530
2530
      }
2531
2531
      key_part_info->length=(uint16) length;
2558
2558
          {
2559
2559
            my_message(ER_MULTIPLE_PRI_KEY, ER(ER_MULTIPLE_PRI_KEY),
2560
2560
                       MYF(0));
2561
 
            DBUG_RETURN(TRUE);
 
2561
            DBUG_RETURN(true);
2562
2562
          }
2563
2563
          key_name=primary_key_name;
2564
2564
          primary_key=1;
2569
2569
        if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
2570
2570
        {
2571
2571
          my_error(ER_DUP_KEYNAME, MYF(0), key_name);
2572
 
          DBUG_RETURN(TRUE);
 
2572
          DBUG_RETURN(true);
2573
2573
        }
2574
2574
        key_info->name=(char*) key_name;
2575
2575
      }
2577
2577
    if (!key_info->name || check_column_name(key_info->name))
2578
2578
    {
2579
2579
      my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
2580
 
      DBUG_RETURN(TRUE);
 
2580
      DBUG_RETURN(true);
2581
2581
    }
2582
2582
    if (!(key_info->flags & HA_NULL_PART_KEY))
2583
2583
      unique_key=1;
2585
2585
    if (key_length > max_key_length)
2586
2586
    {
2587
2587
      my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
2588
 
      DBUG_RETURN(TRUE);
 
2588
      DBUG_RETURN(true);
2589
2589
    }
2590
2590
    key_info++;
2591
2591
  }
2593
2593
      (file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY))
2594
2594
  {
2595
2595
    my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0));
2596
 
    DBUG_RETURN(TRUE);
 
2596
    DBUG_RETURN(true);
2597
2597
  }
2598
2598
  if (auto_increment > 0)
2599
2599
  {
2600
2600
    my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
2601
 
    DBUG_RETURN(TRUE);
 
2601
    DBUG_RETURN(true);
2602
2602
  }
2603
2603
  /* Sort keys in optimized order */
2604
2604
  my_qsort((uchar*) *key_info_buffer, *key_count, sizeof(KEY),
2632
2632
      */
2633
2633
 
2634
2634
      my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
2635
 
      DBUG_RETURN(TRUE);
 
2635
      DBUG_RETURN(true);
2636
2636
    }
2637
2637
  }
2638
2638
 
2639
 
  DBUG_RETURN(FALSE);
 
2639
  DBUG_RETURN(false);
2640
2640
}
2641
2641
 
2642
2642
 
2791
2791
    and must be zero for standard create of table.
2792
2792
 
2793
2793
  RETURN VALUES
2794
 
    FALSE OK
2795
 
    TRUE  error
 
2794
    false OK
 
2795
    true  error
2796
2796
*/
2797
2797
 
2798
2798
bool mysql_create_table_no_lock(THD *thd,
2808
2808
  uint          db_options, key_count;
2809
2809
  KEY           *key_info_buffer;
2810
2810
  handler       *file;
2811
 
  bool          error= TRUE;
 
2811
  bool          error= true;
2812
2812
  DBUG_ENTER("mysql_create_table_no_lock");
2813
2813
  DBUG_PRINT("enter", ("db: '%s'  table: '%s'  tmp: %d",
2814
2814
                       db, table_name, internal_tmp_table));
2819
2819
  {
2820
2820
    my_message(ER_TABLE_MUST_HAVE_COLUMNS, ER(ER_TABLE_MUST_HAVE_COLUMNS),
2821
2821
               MYF(0));
2822
 
    DBUG_RETURN(TRUE);
 
2822
    DBUG_RETURN(true);
2823
2823
  }
2824
2824
  if (check_engine(thd, table_name, create_info))
2825
 
    DBUG_RETURN(TRUE);
 
2825
    DBUG_RETURN(true);
2826
2826
  db_options= create_info->table_options;
2827
2827
  if (create_info->row_type == ROW_TYPE_DYNAMIC)
2828
2828
    db_options|=HA_OPTION_PACK_RECORD;
2831
2831
                              create_info->db_type)))
2832
2832
  {
2833
2833
    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(handler));
2834
 
    DBUG_RETURN(TRUE);
 
2834
    DBUG_RETURN(true);
2835
2835
  }
2836
2836
 
2837
2837
  set_table_default_charset(thd, create_info, (char*) db);
2856
2856
    if (strchr(alias, FN_DEVCHAR))
2857
2857
    {
2858
2858
      my_error(ER_WRONG_TABLE_NAME, MYF(0), alias);
2859
 
      DBUG_RETURN(TRUE);
 
2859
      DBUG_RETURN(true);
2860
2860
    }
2861
2861
#endif
2862
2862
    path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
2982
2982
      (void) rm_temporary_table(create_info->db_type, path, false);
2983
2983
      goto unlock_and_end;
2984
2984
    }
2985
 
    thd->thread_specific_used= TRUE;
 
2985
    thd->thread_specific_used= true;
2986
2986
  }
2987
2987
 
2988
2988
  /*
2996
2996
      (!thd->current_stmt_binlog_row_based ||
2997
2997
       (thd->current_stmt_binlog_row_based &&
2998
2998
        !(create_info->options & HA_LEX_CREATE_TMP_TABLE))))
2999
 
    write_bin_log(thd, TRUE, thd->query, thd->query_length);
3000
 
  error= FALSE;
 
2999
    write_bin_log(thd, true, thd->query, thd->query_length);
 
3000
  error= false;
3001
3001
unlock_and_end:
3002
3002
  VOID(pthread_mutex_unlock(&LOCK_open));
3003
3003
 
3007
3007
  DBUG_RETURN(error);
3008
3008
 
3009
3009
warn:
3010
 
  error= FALSE;
 
3010
  error= false;
3011
3011
  push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
3012
3012
                      ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
3013
3013
                      alias);
3042
3042
  if (thd->killed)
3043
3043
  {
3044
3044
    pthread_mutex_unlock(&LOCK_lock_db);
3045
 
    DBUG_RETURN(TRUE);
 
3045
    DBUG_RETURN(true);
3046
3046
  }
3047
3047
  creating_table++;
3048
3048
  pthread_mutex_unlock(&LOCK_lock_db);
3051
3051
  {
3052
3052
    if (lock_table_name_if_not_cached(thd, db, table_name, &name_lock))
3053
3053
    {
3054
 
      result= TRUE;
 
3054
      result= true;
3055
3055
      goto unlock;
3056
3056
    }
3057
3057
    if (!name_lock)
3062
3062
                            ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
3063
3063
                            table_name);
3064
3064
        create_info->table_existed= 1;
3065
 
        result= FALSE;
 
3065
        result= false;
3066
3066
      }
3067
3067
      else
3068
3068
      {
3069
3069
        my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
3070
 
        result= TRUE;
 
3070
        result= true;
3071
3071
      }
3072
3072
      goto unlock;
3073
3073
    }
3082
3082
  if (name_lock)
3083
3083
  {
3084
3084
    pthread_mutex_lock(&LOCK_open);
3085
 
    unlink_open_table(thd, name_lock, FALSE);
 
3085
    unlink_open_table(thd, name_lock, false);
3086
3086
    pthread_mutex_unlock(&LOCK_open);
3087
3087
  }
3088
3088
  pthread_mutex_lock(&LOCK_lock_db);
3154
3154
                                but only the table in the storage engine.
3155
3155
 
3156
3156
  RETURN
3157
 
    FALSE   OK
3158
 
    TRUE    Error
 
3157
    false   OK
 
3158
    true    Error
3159
3159
*/
3160
3160
 
3161
3161
bool
3251
3251
 
3252
3252
  VOID(table->file->extra(function));
3253
3253
  /* Mark all tables that are in use as 'old' */
3254
 
  mysql_lock_abort(thd, table, TRUE);   /* end threads waiting on lock */
 
3254
  mysql_lock_abort(thd, table, true);   /* end threads waiting on lock */
3255
3255
 
3256
3256
  /* Wait until all there are no other threads that has this table open */
3257
3257
  remove_table_from_cache(thd, table->s->db.str,
3289
3289
    thd->lock=0;                        // Start locked threads
3290
3290
  }
3291
3291
  /* Close all copies of 'table'.  This also frees all LOCK TABLES lock */
3292
 
  unlink_open_table(thd, table, TRUE);
 
3292
  unlink_open_table(thd, table, true);
3293
3293
 
3294
3294
  /* When lock on LOCK_open is freed other threads can continue */
3295
3295
  broadcast_refresh();
3434
3434
    to finish the repair in the handler later on.
3435
3435
  */
3436
3436
  pthread_mutex_lock(&LOCK_open);
3437
 
  if (reopen_name_locked_table(thd, table_list, TRUE))
 
3437
  if (reopen_name_locked_table(thd, table_list, true))
3438
3438
  {
3439
3439
    unlock_table_name(thd, table_list);
3440
3440
    pthread_mutex_unlock(&LOCK_open);
3458
3458
 
3459
3459
/*
3460
3460
  RETURN VALUES
3461
 
    FALSE Message sent to net (admin operation went ok)
3462
 
    TRUE  Message should be sent by caller 
 
3461
    false Message sent to net (admin operation went ok)
 
3462
    true  Message should be sent by caller 
3463
3463
          (admin operation or network communication failed)
3464
3464
*/
3465
3465
static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
3498
3498
  item->maybe_null = 1;
3499
3499
  if (protocol->send_fields(&field_list,
3500
3500
                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
3501
 
    DBUG_RETURN(TRUE);
 
3501
    DBUG_RETURN(true);
3502
3502
 
3503
 
  mysql_ha_rm_tables(thd, tables, FALSE);
 
3503
  mysql_ha_rm_tables(thd, tables, false);
3504
3504
 
3505
3505
  for (table= tables; table; table= table->next_local)
3506
3506
  {
3595
3595
      ha_autocommit_or_rollback(thd, 0);
3596
3596
      end_trans(thd, COMMIT);
3597
3597
      close_thread_tables(thd);
3598
 
      lex->reset_query_tables_list(FALSE);
 
3598
      lex->reset_query_tables_list(false);
3599
3599
      table->table=0;                           // For query cache
3600
3600
      if (protocol->write())
3601
3601
        goto err;
3610
3610
      pthread_mutex_lock(&LOCK_open);
3611
3611
      const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
3612
3612
                                              "Waiting to get writelock");
3613
 
      mysql_lock_abort(thd,table->table, TRUE);
 
3613
      mysql_lock_abort(thd,table->table, true);
3614
3614
      remove_table_from_cache(thd, table->table->s->db.str,
3615
3615
                              table->table->s->table_name.str,
3616
3616
                              RTFC_WAIT_OTHER_THREAD_FLAG |
3730
3730
      protocol->store(STRING_WITH_LEN("status"), system_charset_info);
3731
3731
      protocol->store(STRING_WITH_LEN("Operation need committed state"),
3732
3732
                      system_charset_info);
3733
 
      open_for_modify= FALSE;
 
3733
      open_for_modify= false;
3734
3734
      break;
3735
3735
 
3736
3736
    case HA_ADMIN_ALREADY_DONE:
3870
3870
  }
3871
3871
 
3872
3872
  my_eof(thd);
3873
 
  DBUG_RETURN(FALSE);
 
3873
  DBUG_RETURN(false);
3874
3874
 
3875
3875
err:
3876
3876
  ha_autocommit_or_rollback(thd, 1);
3878
3878
  close_thread_tables(thd);                     // Shouldn't be needed
3879
3879
  if (table)
3880
3880
    table->table=0;
3881
 
  DBUG_RETURN(TRUE);
 
3881
  DBUG_RETURN(true);
3882
3882
}
3883
3883
 
3884
3884
 
3912
3912
    tables      Table list (one table only)
3913
3913
 
3914
3914
  RETURN VALUES
3915
 
   FALSE ok
3916
 
   TRUE  error
 
3915
   false ok
 
3916
   true  error
3917
3917
*/
3918
3918
 
3919
3919
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
3929
3929
  {
3930
3930
    pthread_mutex_unlock(&LOCK_global_system_variables);
3931
3931
    my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str);
3932
 
    DBUG_RETURN(TRUE);
 
3932
    DBUG_RETURN(true);
3933
3933
  }
3934
3934
  pthread_mutex_unlock(&LOCK_global_system_variables);
3935
3935
  check_opt.key_cache= key_cache;
3987
3987
    tables      Table list (one table only)
3988
3988
 
3989
3989
  RETURN VALUES
3990
 
    FALSE ok
3991
 
    TRUE  error
 
3990
    false ok
 
3991
    true  error
3992
3992
*/
3993
3993
 
3994
3994
bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
4065
4065
    create_info Create info
4066
4066
 
4067
4067
  RETURN VALUES
4068
 
    FALSE OK
4069
 
    TRUE  error
 
4068
    false OK
 
4069
    true  error
4070
4070
*/
4071
4071
 
4072
4072
bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
4078
4078
  char *db= table->db;
4079
4079
  char *table_name= table->table_name;
4080
4080
  int  err;
4081
 
  bool res= TRUE;
 
4081
  bool res= true;
4082
4082
  uint not_used;
4083
4083
  DBUG_ENTER("mysql_create_like_table");
4084
4084
 
4096
4096
    operations which matter.
4097
4097
  */
4098
4098
  if (open_tables(thd, &src_table, &not_used, 0))
4099
 
    DBUG_RETURN(TRUE);
 
4099
    DBUG_RETURN(true);
4100
4100
 
4101
4101
  strxmov(src_path, src_table->table->s->path.str, reg_ext, NullS);
4102
4102
 
4228
4228
        */
4229
4229
        table->table= name_lock;
4230
4230
        VOID(pthread_mutex_lock(&LOCK_open));
4231
 
        if (reopen_name_locked_table(thd, table, FALSE))
 
4231
        if (reopen_name_locked_table(thd, table, false))
4232
4232
        {
4233
4233
          VOID(pthread_mutex_unlock(&LOCK_open));
4234
4234
          goto err;
4239
4239
                                               create_info);
4240
4240
 
4241
4241
        DBUG_ASSERT(result == 0); // store_create_info() always return 0
4242
 
        write_bin_log(thd, TRUE, query.ptr(), query.length());
 
4242
        write_bin_log(thd, true, query.ptr(), query.length());
4243
4243
      }
4244
4244
      else                                      // Case 1
4245
 
        write_bin_log(thd, TRUE, thd->query, thd->query_length);
 
4245
        write_bin_log(thd, true, thd->query, thd->query_length);
4246
4246
    }
4247
4247
    /*
4248
4248
      Case 3 and 4 does nothing under RBR
4249
4249
    */
4250
4250
  }
4251
4251
  else
4252
 
    write_bin_log(thd, TRUE, thd->query, thd->query_length);
 
4252
    write_bin_log(thd, true, thd->query, thd->query_length);
4253
4253
 
4254
 
  res= FALSE;
 
4254
  res= false;
4255
4255
  goto err;
4256
4256
 
4257
4257
table_exists:
4262
4262
                ER(ER_TABLE_EXISTS_ERROR), table_name);
4263
4263
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
4264
4264
                 ER_TABLE_EXISTS_ERROR,warn_buff);
4265
 
    res= FALSE;
 
4265
    res= false;
4266
4266
  }
4267
4267
  else
4268
4268
    my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
4271
4271
  if (name_lock)
4272
4272
  {
4273
4273
    pthread_mutex_lock(&LOCK_open);
4274
 
    unlink_open_table(thd, name_lock, FALSE);
 
4274
    unlink_open_table(thd, name_lock, false);
4275
4275
    pthread_mutex_unlock(&LOCK_open);
4276
4276
  }
4277
4277
  DBUG_RETURN(res);
4325
4325
   We set this flag so that ha_innobase::open and ::external_lock() do
4326
4326
   not complain when we lock the table
4327
4327
 */
4328
 
  thd->tablespace_op= TRUE;
 
4328
  thd->tablespace_op= true;
4329
4329
  if (!(table=open_ltable(thd, table_list, TL_WRITE, 0)))
4330
4330
  {
4331
 
    thd->tablespace_op=FALSE;
 
4331
    thd->tablespace_op=false;
4332
4332
    DBUG_RETURN(-1);
4333
4333
  }
4334
4334
 
4345
4345
    error=1;
4346
4346
  if (error)
4347
4347
    goto err;
4348
 
  write_bin_log(thd, FALSE, thd->query, thd->query_length);
 
4348
  write_bin_log(thd, false, thd->query, thd->query_length);
4349
4349
 
4350
4350
err:
4351
4351
  ha_autocommit_or_rollback(thd, error);
4352
 
  thd->tablespace_op=FALSE;
 
4352
  thd->tablespace_op=false;
4353
4353
  
4354
4354
  if (error == 0)
4355
4355
  {
4424
4424
   table->key_info or key_info_buffer respectively for the indexes
4425
4425
   that need to be dropped and/or (re-)created.
4426
4426
 
4427
 
   @retval TRUE  error
4428
 
   @retval FALSE success
 
4427
   @retval true  error
 
4428
   @retval false success
4429
4429
*/
4430
4430
 
4431
4431
static
4480
4480
                                   &ha_alter_info->key_info_buffer,
4481
4481
                                   &ha_alter_info->key_count,
4482
4482
                                   /* select_field_count */ 0))
4483
 
      DBUG_RETURN(TRUE);
 
4483
      DBUG_RETURN(true);
4484
4484
    /* Allocate result buffers. */
4485
4485
    if (! (ha_alter_info->index_drop_buffer=
4486
4486
           (uint*) thd->alloc(sizeof(uint) * table->s->keys)) ||
4487
4487
        ! (ha_alter_info->index_add_buffer=
4488
4488
           (uint*) thd->alloc(sizeof(uint) *
4489
4489
                              tmp_alter_info.key_list.elements)))
4490
 
      DBUG_RETURN(TRUE);
 
4490
      DBUG_RETURN(true);
4491
4491
  }
4492
4492
  /*
4493
4493
    First we setup ha_alter_flags based on what was detected
4793
4793
  }
4794
4794
#endif
4795
4795
 
4796
 
  DBUG_RETURN(FALSE);
 
4796
  DBUG_RETURN(false);
4797
4797
}
4798
4798
 
4799
4799
 
4808
4808
      keys_onoff             ENABLE | DISABLE | LEAVE_AS_IS
4809
4809
 
4810
4810
  RETURN VALUES
4811
 
    FALSE  OK
4812
 
    TRUE   Error
 
4811
    false  OK
 
4812
    true   Error
4813
4813
*/
4814
4814
 
4815
4815
static
5170
5170
    Sets create_info->varchar if the table has a VARCHAR column.
5171
5171
    Prepares alter_info->create_list and alter_info->key_list with
5172
5172
    columns and keys of the new table.
5173
 
  @retval TRUE   error, out of memory or a semantical error in ALTER
 
5173
  @retval true   error, out of memory or a semantical error in ALTER
5174
5174
                 TABLE instructions
5175
 
  @retval FALSE  success
 
5175
  @retval false  success
5176
5176
*/
5177
5177
 
5178
5178
static bool
5195
5195
                           & ~(HA_OPTION_PACK_RECORD));
5196
5196
  uint used_fields= create_info->used_fields;
5197
5197
  KEY *key_info=table->key_info;
5198
 
  bool rc= TRUE;
 
5198
  bool rc= true;
5199
5199
 
5200
5200
  DBUG_ENTER("mysql_prepare_alter_table");
5201
5201
 
5202
 
  create_info->varchar= FALSE;
 
5202
  create_info->varchar= false;
5203
5203
  /* Let new create options override the old ones */
5204
5204
  if (!(used_fields & HA_CREATE_USED_MIN_ROWS))
5205
5205
    create_info->min_rows= table->s->min_rows;
5230
5230
  for (f_ptr=table->field ; (field= *f_ptr) ; f_ptr++)
5231
5231
    {
5232
5232
    if (field->type() == MYSQL_TYPE_STRING)
5233
 
      create_info->varchar= TRUE;
 
5233
      create_info->varchar= true;
5234
5234
    /* Check if field should be dropped */
5235
5235
    Alter_drop *drop;
5236
5236
    drop_it.rewind();
5324
5324
         thd->variables.sql_mode & MODE_NO_ZERO_DATE)
5325
5325
    {
5326
5326
        alter_info->datetime_field= def;
5327
 
        alter_info->error_if_not_empty= TRUE;
 
5327
        alter_info->error_if_not_empty= true;
5328
5328
    }
5329
5329
    if (!def->after)
5330
5330
      new_create_list.push_back(def);
5530
5530
  if (table->s->tmp_table)
5531
5531
    create_info->options|=HA_LEX_CREATE_TMP_TABLE;
5532
5532
 
5533
 
  rc= FALSE;
 
5533
  rc= false;
5534
5534
  alter_info->create_list.swap(new_create_list);
5535
5535
  alter_info->key_list.swap(new_key_list);
5536
5536
err:
5576
5576
    tables.
5577
5577
 
5578
5578
  RETURN VALUES
5579
 
    FALSE  OK
5580
 
    TRUE   Error
 
5579
    false  OK
 
5580
    true   Error
5581
5581
*/
5582
5582
 
5583
5583
bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
5600
5600
  if (table_list && table_list->schema_table)
5601
5601
  {
5602
5602
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.str);
5603
 
    DBUG_RETURN(TRUE);
 
5603
    DBUG_RETURN(true);
5604
5604
  }
5605
5605
 
5606
5606
  /*
5616
5616
    new_db= db;
5617
5617
  build_table_filename(path, sizeof(path), db, table_name, "", 0);
5618
5618
 
5619
 
  mysql_ha_rm_tables(thd, table_list, FALSE);
 
5619
  mysql_ha_rm_tables(thd, table_list, false);
5620
5620
 
5621
5621
  /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */
5622
5622
  if (alter_info->tablespace_op != NO_TABLESPACE_OP)
5642
5642
  frm_type= mysql_frm_type(thd, new_name_buff, &table_type);
5643
5643
 
5644
5644
  if (!(table= open_n_lock_single_table(thd, table_list, TL_WRITE_ALLOW_READ)))
5645
 
    DBUG_RETURN(TRUE);
 
5645
    DBUG_RETURN(true);
5646
5646
  table->use_all_columns();
5647
5647
 
5648
5648
  /*
5656
5656
      (table->s->tmp_table == NO_TMP_TABLE))
5657
5657
  {
5658
5658
    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
5659
 
    DBUG_RETURN(TRUE);
 
5659
    DBUG_RETURN(true);
5660
5660
  }
5661
5661
 
5662
5662
  /* Check that we are not trying to rename to an existing table */
5690
5690
        if (find_temporary_table(thd,new_db,new_name_buff))
5691
5691
        {
5692
5692
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name_buff);
5693
 
          DBUG_RETURN(TRUE);
 
5693
          DBUG_RETURN(true);
5694
5694
        }
5695
5695
      }
5696
5696
      else
5697
5697
      {
5698
5698
        if (lock_table_name_if_not_cached(thd, new_db, new_name, &name_lock))
5699
 
          DBUG_RETURN(TRUE);
 
5699
          DBUG_RETURN(true);
5700
5700
        if (!name_lock)
5701
5701
        {
5702
5702
          my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
5703
 
          DBUG_RETURN(TRUE);
 
5703
          DBUG_RETURN(true);
5704
5704
        }
5705
5705
 
5706
5706
        build_table_filename(new_name_buff, sizeof(new_name_buff),
5783
5783
      /* COND_refresh will be signaled in close_thread_tables() */
5784
5784
      break;
5785
5785
    default:
5786
 
      DBUG_ASSERT(FALSE);
 
5786
      DBUG_ASSERT(false);
5787
5787
      error= 0;
5788
5788
      break;
5789
5789
    }
5850
5850
 
5851
5851
    if (!error)
5852
5852
    {
5853
 
      write_bin_log(thd, TRUE, thd->query, thd->query_length);
 
5853
      write_bin_log(thd, true, thd->query, thd->query_length);
5854
5854
      my_ok(thd);
5855
5855
  }
5856
5856
    else if (error > 0)
5859
5859
      error= -1;
5860
5860
    }
5861
5861
    if (name_lock)
5862
 
      unlink_open_table(thd, name_lock, FALSE);
 
5862
      unlink_open_table(thd, name_lock, false);
5863
5863
    VOID(pthread_mutex_unlock(&LOCK_open));
5864
5864
    table_list->table= NULL;                    // For query cache
5865
5865
    DBUG_RETURN(error);
5904
5904
    HA_ALTER_INFO ha_alter_info;
5905
5905
    HA_ALTER_FLAGS ha_alter_flags;
5906
5906
    uint table_changes= IS_EQUAL_YES;
5907
 
    bool need_copy_table= TRUE;
 
5907
    bool need_copy_table= true;
5908
5908
    /* Check how much the tables differ. */
5909
5909
    if (compare_tables(thd, table, alter_info,
5910
5910
                       create_info, order_num,
5912
5912
                       &ha_alter_info,
5913
5913
                       &table_changes))
5914
5914
    {
5915
 
      DBUG_RETURN(TRUE);
 
5915
      DBUG_RETURN(true);
5916
5916
    }
5917
5917
 
5918
5918
    /*
5967
5967
          call check_if_supported_alter has provision for this
5968
5968
          already now.
5969
5969
        */
5970
 
        need_copy_table= FALSE;
 
5970
        need_copy_table= false;
5971
5971
        break;
5972
5972
      case HA_ALTER_NOT_SUPPORTED:
5973
5973
        if (alter_info->build_method == HA_BUILD_ONLINE)
5976
5976
          close_temporary_table(thd, altered_table, 1, 1);
5977
5977
          goto err;
5978
5978
        }
5979
 
        need_copy_table= TRUE;
 
5979
        need_copy_table= true;
5980
5980
        break;
5981
5981
      case HA_ALTER_ERROR:
5982
5982
      default:
5996
5996
    }
5997
5997
    /* TODO need to check if changes can be handled as fast ALTER TABLE */
5998
5998
    if (!altered_table)
5999
 
      need_copy_table= TRUE;
 
5999
      need_copy_table= true;
6000
6000
 
6001
6001
    if (!need_copy_table)
6002
6002
    {
6123
6123
      goto err1;
6124
6124
    /* We don't replicate alter table statement on temporary tables */
6125
6125
    if (!thd->current_stmt_binlog_row_based)
6126
 
      write_bin_log(thd, TRUE, thd->query, thd->query_length);
 
6126
      write_bin_log(thd, true, thd->query, thd->query_length);
6127
6127
    goto end_temporary;
6128
6128
  }
6129
6129
 
6232
6232
  DBUG_ASSERT(!(mysql_bin_log.is_open() &&
6233
6233
                thd->current_stmt_binlog_row_based &&
6234
6234
                (create_info->options & HA_LEX_CREATE_TMP_TABLE)));
6235
 
  write_bin_log(thd, TRUE, thd->query, thd->query_length);
 
6235
  write_bin_log(thd, true, thd->query, thd->query_length);
6236
6236
 
6237
6237
  if (ha_check_storage_engine_flag(old_db_type, HTON_FLUSH_AFTER_RENAME))
6238
6238
  {
6244
6244
    char path[FN_REFLEN];
6245
6245
    TABLE *t_table;
6246
6246
    build_table_filename(path, sizeof(path), new_db, table_name, "", 0);
6247
 
    t_table= open_temporary_table(thd, path, new_db, tmp_name, FALSE, OTM_OPEN);
 
6247
    t_table= open_temporary_table(thd, path, new_db, tmp_name, false, OTM_OPEN);
6248
6248
    if (t_table)
6249
6249
    {
6250
6250
      intern_close_table(t_table);
6266
6266
      LOCK TABLES we can rely on close_thread_tables() doing this job.
6267
6267
    */
6268
6268
    pthread_mutex_lock(&LOCK_open);
6269
 
    unlink_open_table(thd, table, FALSE);
6270
 
    unlink_open_table(thd, name_lock, FALSE);
 
6269
    unlink_open_table(thd, table, false);
 
6270
    unlink_open_table(thd, name_lock, false);
6271
6271
    pthread_mutex_unlock(&LOCK_open);
6272
6272
  }
6273
6273
 
6277
6277
              (ulong) thd->cuted_fields);
6278
6278
  my_ok(thd, copied + deleted, 0L, tmp_name);
6279
6279
  thd->some_tables_deleted=0;
6280
 
  DBUG_RETURN(FALSE);
 
6280
  DBUG_RETURN(false);
6281
6281
 
6282
6282
err1:
6283
6283
  if (new_table)
6315
6315
        DBUG_ASSERT(0);
6316
6316
    }
6317
6317
    bool save_abort_on_warning= thd->abort_on_warning;
6318
 
    thd->abort_on_warning= TRUE;
 
6318
    thd->abort_on_warning= true;
6319
6319
    make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
6320
6320
                                 f_val, strlength(f_val), t_type,
6321
6321
                                 alter_info->datetime_field->field_name);
6324
6324
  if (name_lock)
6325
6325
  {
6326
6326
    pthread_mutex_lock(&LOCK_open);
6327
 
    unlink_open_table(thd, name_lock, FALSE);
 
6327
    unlink_open_table(thd, name_lock, false);
6328
6328
    pthread_mutex_unlock(&LOCK_open);
6329
6329
  }
6330
 
  DBUG_RETURN(TRUE);
 
6330
  DBUG_RETURN(true);
6331
6331
 
6332
6332
err_with_placeholders:
6333
6333
  /*
6335
6335
    being altered. To be safe under LOCK TABLES we should remove placeholders
6336
6336
    from list of open tables list and table cache.
6337
6337
  */
6338
 
  unlink_open_table(thd, table, FALSE);
 
6338
  unlink_open_table(thd, table, false);
6339
6339
  if (name_lock)
6340
 
    unlink_open_table(thd, name_lock, FALSE);
 
6340
    unlink_open_table(thd, name_lock, false);
6341
6341
  VOID(pthread_mutex_unlock(&LOCK_open));
6342
 
  DBUG_RETURN(TRUE);
 
6342
  DBUG_RETURN(true);
6343
6343
}
6344
6344
/* mysql_alter_table */
6345
6345
 
6375
6375
    
6376
6376
    This needs to be done before external_lock
6377
6377
  */
6378
 
  error= ha_enable_transaction(thd, FALSE);
 
6378
  error= ha_enable_transaction(thd, false);
6379
6379
  if (error)
6380
6380
    DBUG_RETURN(-1);
6381
6381
  
6406
6406
    {
6407
6407
      if (*ptr == to->next_number_field)
6408
6408
      {
6409
 
        auto_increment_field_copied= TRUE;
 
6409
        auto_increment_field_copied= true;
6410
6410
        /*
6411
6411
          If we are going to copy contents of one auto_increment column to
6412
6412
          another auto_increment column it is sensible to preserve zeroes.
6481
6481
    if (to->next_number_field)
6482
6482
    {
6483
6483
      if (auto_increment_field_copied)
6484
 
        to->auto_increment_field_not_null= TRUE;
 
6484
        to->auto_increment_field_not_null= true;
6485
6485
      else
6486
6486
        to->next_number_field->reset();
6487
6487
    }
6492
6492
    }
6493
6493
    prev_insert_id= to->file->next_insert_id;
6494
6494
    error=to->file->ha_write_row(to->record[0]);
6495
 
    to->auto_increment_field_not_null= FALSE;
 
6495
    to->auto_increment_field_not_null= false;
6496
6496
    if (error)
6497
6497
    {
6498
6498
      if (!ignore ||
6533
6533
  }
6534
6534
  to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
6535
6535
 
6536
 
  if (ha_enable_transaction(thd, TRUE))
 
6536
  if (ha_enable_transaction(thd, true))
6537
6537
  {
6538
6538
    error= 1;
6539
6539
    goto err;
6612
6612
  item->maybe_null= 1;
6613
6613
  if (protocol->send_fields(&field_list,
6614
6614
                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
6615
 
    DBUG_RETURN(TRUE);
 
6615
    DBUG_RETURN(true);
6616
6616
 
6617
6617
  /* Open one table after the other to keep lock time as short as possible. */
6618
6618
  for (table= tables; table; table= table->next_local)
6704
6704
  }
6705
6705
 
6706
6706
  my_eof(thd);
6707
 
  DBUG_RETURN(FALSE);
 
6707
  DBUG_RETURN(false);
6708
6708
 
6709
6709
 err:
6710
6710
  close_thread_tables(thd);                     // Shouldn't be needed
6711
6711
  if (table)
6712
6712
    table->table=0;
6713
 
  DBUG_RETURN(TRUE);
 
6713
  DBUG_RETURN(true);
6714
6714
}
6715
6715
 
6716
6716
static bool check_engine(THD *thd, const char *table_name,
6721
6721
  bool no_substitution= 1;
6722
6722
  if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
6723
6723
                                  no_substitution, 1)))
6724
 
    return TRUE;
 
6724
    return true;
6725
6725
 
6726
6726
  if (req_engine && req_engine != *new_engine)
6727
6727
  {
6739
6739
      my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
6740
6740
               ha_resolve_storage_engine_name(*new_engine), "TEMPORARY");
6741
6741
      *new_engine= 0;
6742
 
      return TRUE;
 
6742
      return true;
6743
6743
    }
6744
6744
    *new_engine= myisam_hton;
6745
6745
  }
6746
 
  return FALSE;
 
6746
  return false;
6747
6747
}