~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
345
345
    drop_temporary      Only drop temporary tables
346
346
    drop_view           Allow to delete VIEW .frm
347
347
    dont_log_query      Don't write query to log files. This will also not
348
 
                        generate warnings if the handler files doesn't exists  
 
348
                        generate warnings if the handler files doesn't exists
349
349
 
350
350
  TODO:
351
351
    When logging to the binary log, we should log
500
500
      *(end= path + path_length - reg_ext_length)= '\0';
501
501
      error= ha_delete_table(session, path, db, table->table_name,
502
502
                             !dont_log_query);
503
 
      if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && 
 
503
      if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) &&
504
504
          if_exists)
505
505
      {
506
506
        error= 0;
658
658
static int sort_keys(KEY *a, KEY *b)
659
659
{
660
660
  ulong a_flags= a->flags, b_flags= b->flags;
661
 
  
 
661
 
662
662
  if (a_flags & HA_NOSAME)
663
663
  {
664
664
    if (!(b_flags & HA_NOSAME))
714
714
  TYPELIB tmp= *typelib;
715
715
  const char **cur_value= typelib->type_names;
716
716
  unsigned int *cur_length= typelib->type_lengths;
717
 
  *dup_val_count= 0;  
718
 
  
 
717
  *dup_val_count= 0;
 
718
 
719
719
  for ( ; tmp.count > 1; cur_value++, cur_length++)
720
720
  {
721
721
    tmp.type_names++;
785
785
   1    Error
786
786
*/
787
787
 
788
 
int prepare_create_field(Create_field *sql_field, 
 
788
int prepare_create_field(Create_field *sql_field,
789
789
                         uint32_t *blob_columns,
790
790
                         int *timestamps, int *timestamps_with_niladic,
791
791
                         int64_t table_flags __attribute__((unused)))
962
962
      Convert the default value from client character
963
963
      set into the column character set if necessary.
964
964
    */
965
 
    if (sql_field->def && 
 
965
    if (sql_field->def &&
966
966
        save_cs != sql_field->def->collation.collation &&
967
967
        (sql_field->sql_type == DRIZZLE_TYPE_ENUM))
968
968
    {
1010
1010
        String conv, *tmp;
1011
1011
        char comma_buf[4];
1012
1012
        int comma_length= cs->cset->wc_mb(cs, ',', (unsigned char*) comma_buf,
1013
 
                                          (unsigned char*) comma_buf + 
 
1013
                                          (unsigned char*) comma_buf +
1014
1014
                                          sizeof(comma_buf));
1015
1015
        assert(comma_length > 0);
1016
1016
        for (uint32_t i= 0; (tmp= int_it++); i++)
1051
1051
            }
1052
1052
 
1053
1053
            /* else, the defaults yield the correct length for NULLs. */
1054
 
          } 
 
1054
          }
1055
1055
          else /* not NULL */
1056
1056
          {
1057
1057
            def->length(cs->cset->lengthsp(cs, def->ptr(), def->length()));
1111
1111
          sql_field->decimals=          dup_field->decimals;
1112
1112
          sql_field->create_length_to_internal_length();
1113
1113
          sql_field->unireg_check=      dup_field->unireg_check;
1114
 
          /* 
 
1114
          /*
1115
1115
            We're making one field from two, the result field will have
1116
1116
            dup_field->flags as flags. If we've incremented null_fields
1117
1117
            because of sql_field->flags, decrement it back.
1144
1144
  {
1145
1145
    assert(sql_field->charset != 0);
1146
1146
 
1147
 
    if (prepare_create_field(sql_field, &blob_columns, 
 
1147
    if (prepare_create_field(sql_field, &blob_columns,
1148
1148
                             &timestamps, &timestamps_with_niladic,
1149
1149
                             file->ha_table_flags()))
1150
1150
      return(true);
1155
1155
      auto_increment++;
1156
1156
    /*
1157
1157
          For now skip fields that are not physically stored in the database
1158
 
          (virtual fields) and update their offset later 
 
1158
          (virtual fields) and update their offset later
1159
1159
          (see the next loop).
1160
1160
        */
1161
1161
    if (sql_field->is_stored)
1681
1681
             MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen);
1682
1682
    return(1);
1683
1683
  }
1684
 
    
 
1684
 
1685
1685
  if ((sql_field->flags & BLOB_FLAG) && sql_field->length)
1686
1686
  {
1687
1687
    if (sql_field->sql_type == DRIZZLE_TYPE_BLOB)
1709
1709
    keys                List of keys to create
1710
1710
    internal_tmp_table  Set to 1 if this is an internal temporary table
1711
1711
                        (From ALTER Table)
1712
 
    select_field_count  
 
1712
    select_field_count
1713
1713
 
1714
1714
  DESCRIPTION
1715
1715
    If one creates a temporary table, this is automatically opened
1779
1779
    path_length= build_tmptable_filename(session, path, sizeof(path));
1780
1780
    create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
1781
1781
  }
1782
 
  else  
 
1782
  else
1783
1783
  {
1784
1784
 #ifdef FN_DEVCHAR
1785
1785
    /* check if the table name contains FN_DEVCHAR when defined */
2303
2303
    Check if this is a table type that stores index and data separately,
2304
2304
    like ISAM or MyISAM. We assume fixed order of engine file name
2305
2305
    extentions array. First element of engine file name extentions array
2306
 
    is meta/index file extention. Second element - data file extention. 
 
2306
    is meta/index file extention. Second element - data file extention.
2307
2307
  */
2308
2308
  ext= table->file->bas_ext();
2309
2309
  if (!ext[0] || !ext[1])
2387
2387
/*
2388
2388
  RETURN VALUES
2389
2389
    false Message sent to net (admin operation went ok)
2390
 
    true  Message should be sent by caller 
 
2390
    true  Message should be sent by caller
2391
2391
          (admin operation or network communication failed)
2392
2392
*/
2393
2393
static bool mysql_admin_table(Session* session, TableList* tables,
2566
2566
        /*
2567
2567
          mysql_recreate_table() can push OK or ERROR.
2568
2568
          Clear 'OK' status. If there is an error, keep it:
2569
 
          we will store the error message in a result set row 
 
2569
          we will store the error message in a result set row
2570
2570
          and then clear.
2571
2571
        */
2572
2572
        if (session->main_da.is_ok())
2679
2679
      /*
2680
2680
        mysql_recreate_table() can push OK or ERROR.
2681
2681
        Clear 'OK' status. If there is an error, keep it:
2682
 
        we will store the error message in a result set row 
 
2682
        we will store the error message in a result set row
2683
2683
        and then clear.
2684
2684
      */
2685
2685
      if (session->main_da.is_ok())
2887
2887
  @brief          Create frm file based on I_S table
2888
2888
 
2889
2889
  @param[in]      session                      thread handler
2890
 
  @param[in]      schema_table             I_S table           
 
2890
  @param[in]      schema_table             I_S table
2891
2891
  @param[in]      dst_path                 path where frm should be created
2892
2892
  @param[in]      create_info              Create info
2893
2893
 
2969
2969
 
2970
2970
  strxmov(src_path, src_table->table->s->path.str, reg_ext, NULL);
2971
2971
 
2972
 
  /* 
 
2972
  /*
2973
2973
    Check that destination tables does not exist. Note that its name
2974
2974
    was already checked when it was added to the table list.
2975
2975
  */
3205
3205
err:
3206
3206
  ha_autocommit_or_rollback(session, error);
3207
3207
  session->tablespace_op=false;
3208
 
  
 
3208
 
3209
3209
  if (error == 0)
3210
3210
  {
3211
3211
    my_ok(session);
3213
3213
  }
3214
3214
 
3215
3215
  table->file->print_error(error, MYF(0));
3216
 
    
 
3216
 
3217
3217
  return(-1);
3218
3218
}
3219
3219
 
3431
3431
      /*
3432
3432
        Check if the altered column is a stored virtual field.
3433
3433
        TODO: Mark such a column with an alter flag only if
3434
 
        the expression functions are not equal. 
 
3434
        the expression functions are not equal.
3435
3435
      */
3436
3436
      if (field->is_stored && field->vcol_info)
3437
3437
        *alter_flags|= HA_ALTER_STORED_VCOL;
3852
3852
 
3853
3853
    /*
3854
3854
       Tell the storage engine to perform the online alter table
3855
 
       TODO: 
 
3855
       TODO:
3856
3856
       if check_if_supported_alter() returned HA_ALTER_SUPPORTED_WAIT_LOCK
3857
3857
       we need to wrap the next call with a DDL lock.
3858
3858
     */
4821
4821
 
4822
4822
 
4823
4823
  /* Create a temporary table with the new format */
4824
 
  if ((error= create_temporary_table(session, table, new_db, tmp_name, 
4825
 
                                     create_info, alter_info, 
 
4824
  if ((error= create_temporary_table(session, table, new_db, tmp_name,
 
4825
                                     create_info, alter_info,
4826
4826
                                     !strcmp(db, new_db))))
4827
4827
  {
4828
4828
    goto err;
5138
5138
  /*
5139
5139
    Turn off recovery logging since rollback of an alter table is to
5140
5140
    delete the new table so there is no need to log the changes to it.
5141
 
    
 
5141
 
5142
5142
    This needs to be done before external_lock
5143
5143
  */
5144
5144
  error= ha_enable_transaction(session, false);
5145
5145
  if (error)
5146
5146
    return(-1);
5147
 
  
 
5147
 
5148
5148
  if (!(copy= new Copy_field[to->s->fields]))
5149
5149
    return(-1);                         /* purecov: inspected */
5150
5150
 
5185
5185
    if (to->s->primary_key != MAX_KEY && to->file->primary_key_is_clustered())
5186
5186
    {
5187
5187
      char warn_buff[DRIZZLE_ERRMSG_SIZE];
5188
 
      snprintf(warn_buff, sizeof(warn_buff), 
 
5188
      snprintf(warn_buff, sizeof(warn_buff),
5189
5189
               _("order_st BY ignored because there is a user-defined clustered "
5190
5190
                 "index in the table '%-.192s'"),
5191
5191
               from->s->table_name.str);
5244
5244
      else
5245
5245
        to->next_number_field->reset();
5246
5246
    }
5247
 
    
 
5247
 
5248
5248
    for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
5249
5249
    {
5250
5250
      copy_ptr->do_copy(copy_ptr);