~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Grant Limberg
  • Date: 2008-08-12 21:29:49 UTC
  • mfrom: (322 drizzle)
  • mto: (322.1.1 codestyle)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: grant@glsoftware.net-20080812212949-i7vl3lz5y7u7tdry
Merge from trunk

Did a global search and replace for MYSQL_* variables.  Renamed to DRIZZLE_*.

Renamed value of DRIZZLE_CONFIG_NAME from "my" to "drizzled"

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                              uint types, char **names);
36
36
static uint find_field(Field **fields, uchar *record, uint start, uint length);
37
37
 
38
 
/**************************************************************************
39
 
  Object_creation_ctx implementation.
40
 
**************************************************************************/
41
 
 
42
 
Object_creation_ctx *Object_creation_ctx::set_n_backup(THD *thd)
43
 
{
44
 
  Object_creation_ctx *backup_ctx;
45
 
 
46
 
  backup_ctx= create_backup_ctx(thd);
47
 
  change_env(thd);
48
 
 
49
 
  return(backup_ctx);
50
 
}
51
 
 
52
 
void Object_creation_ctx::restore_env(THD *thd, Object_creation_ctx *backup_ctx)
53
 
{
54
 
  if (!backup_ctx)
55
 
    return;
56
 
 
57
 
  backup_ctx->change_env(thd);
58
 
 
59
 
  delete backup_ctx;
60
 
}
61
 
 
62
 
/**************************************************************************
63
 
  Default_object_creation_ctx implementation.
64
 
**************************************************************************/
65
 
 
66
 
Default_object_creation_ctx::Default_object_creation_ctx(THD *thd)
67
 
  : m_client_cs(thd->variables.character_set_client),
68
 
    m_connection_cl(thd->variables.collation_connection)
69
 
{ }
70
 
 
71
 
Default_object_creation_ctx::Default_object_creation_ctx(
72
 
  const CHARSET_INFO * const client_cs, const CHARSET_INFO * const connection_cl)
73
 
  : m_client_cs(client_cs),
74
 
    m_connection_cl(connection_cl)
75
 
{ }
76
 
 
77
 
Object_creation_ctx *
78
 
Default_object_creation_ctx::create_backup_ctx(THD *thd) const
79
 
{
80
 
  return new Default_object_creation_ctx(thd);
81
 
}
82
 
 
83
 
void Default_object_creation_ctx::change_env(THD *thd) const
84
 
{
85
 
  thd->variables.character_set_client= m_client_cs;
86
 
  thd->variables.collation_connection= m_connection_cl;
87
 
 
88
 
  thd->update_charset();
89
 
}
90
 
 
91
38
/*************************************************************************/
92
39
 
93
40
/* Get column name from column hash */
968
915
      TYPELIB *interval= share->intervals + interval_nr - 1;
969
916
      unhex_type2(interval);
970
917
    }
971
 
    
972
 
#ifndef TO_BE_DELETED_ON_PRODUCTION
973
 
    if (field_type == DRIZZLE_TYPE_NEWDECIMAL && !share->mysql_version)
974
 
    {
975
 
      /*
976
 
        Fix pack length of old decimal values from 5.0.3 -> 5.0.4
977
 
        The difference is that in the old version we stored precision
978
 
        in the .frm table while we now store the display_length
979
 
      */
980
 
      uint decimals= f_decimals(pack_flag);
981
 
      field_length= my_decimal_precision_to_length(field_length,
982
 
                                                   decimals,
983
 
                                                   f_is_dec(pack_flag) == 0);
984
 
      sql_print_error(_("Found incompatible DECIMAL field '%s' in %s; "
985
 
                      "Please do \"ALTER TABLE '%s' FORCE\" to fix it!"),
986
 
                      share->fieldnames.type_names[i], share->table_name.str,
987
 
                      share->table_name.str);
988
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
989
 
                          ER_CRASHED_ON_USAGE,
990
 
                          _("Found incompatible DECIMAL field '%s' in %s; "
991
 
                          "Please do \"ALTER TABLE '%s' FORCE\" to fix it!"),
992
 
                          share->fieldnames.type_names[i],
993
 
                          share->table_name.str,
994
 
                          share->table_name.str);
995
 
      share->crashed= 1;                        // Marker for CHECK TABLE
996
 
    }
997
 
#endif
998
918
 
999
919
    *field_ptr= reg_field=
1000
920
      make_field(share, record+recpos,
1145
1065
        }
1146
1066
        if (field->key_length() != key_part->length)
1147
1067
        {
1148
 
#ifndef TO_BE_DELETED_ON_PRODUCTION
1149
 
          if (field->type() == DRIZZLE_TYPE_NEWDECIMAL)
1150
 
          {
1151
 
            /*
1152
 
              Fix a fatal error in decimal key handling that causes crashes
1153
 
              on Innodb. We fix it by reducing the key length so that
1154
 
              InnoDB never gets a too big key when searching.
1155
 
              This allows the end user to do an ALTER TABLE to fix the
1156
 
              error.
1157
 
            */
1158
 
            keyinfo->key_length-= (key_part->length - field->key_length());
1159
 
            key_part->store_length-= (uint16_t)(key_part->length -
1160
 
                                              field->key_length());
1161
 
            key_part->length= (uint16_t)field->key_length();
1162
 
            sql_print_error(_("Found wrong key definition in %s; "
1163
 
                            "Please do \"ALTER TABLE '%s' FORCE \" to fix it!"),
1164
 
                            share->table_name.str,
1165
 
                            share->table_name.str);
1166
 
            push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1167
 
                                ER_CRASHED_ON_USAGE,
1168
 
                                _("Found wrong key definition in %s; "
1169
 
                                "Please do \"ALTER TABLE '%s' FORCE\" to fix "
1170
 
                                "it!"),
1171
 
                                share->table_name.str,
1172
 
                                share->table_name.str);
1173
 
            share->crashed= 1;                // Marker for CHECK TABLE
1174
 
            continue;
1175
 
          }
1176
 
#endif
1177
1068
          key_part->key_part_flag|= HA_PART_KEY_SEG;
1178
1069
        }
1179
1070
      }