~james-page/ubuntu/precise/mysql-5.5/misc-fixes

« back to all changes in this revision

Viewing changes to sql/sql_table.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-06-11 07:34:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120611073433-l9za2ni4ipp848y3
Tags: 5.5.24-0ubuntu0.12.04.1
* SECURITY UPDATE: Update to 5.5.24 to fix security issues (LP: #1011371)
  - http://dev.mysql.com/doc/refman/5.5/en/news-5-5-24.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
                                    bool error_if_not_empty);
70
70
 
71
71
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
72
 
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
 
72
static bool check_engine(THD *thd, const char *db_name,
 
73
                         const char *table_name,
 
74
                         HA_CREATE_INFO *create_info);
 
75
 
73
76
static int
74
77
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
75
78
                           Alter_info *alter_info,
3940
3943
               MYF(0));
3941
3944
    DBUG_RETURN(TRUE);
3942
3945
  }
3943
 
  if (check_engine(thd, table_name, create_info))
 
3946
  if (check_engine(thd, db, table_name, create_info))
3944
3947
    DBUG_RETURN(TRUE);
3945
3948
 
3946
3949
  set_table_default_charset(thd, create_info, (char*) db);
5923
5926
      create_info->db_type= old_db_type;
5924
5927
  }
5925
5928
 
5926
 
  if (check_engine(thd, new_name, create_info))
 
5929
  if (check_engine(thd, new_db, new_name, create_info))
5927
5930
    goto err;
5928
5931
  new_db_type= create_info->db_type;
5929
5932
 
7342
7345
  DBUG_RETURN(TRUE);
7343
7346
}
7344
7347
 
7345
 
static bool check_engine(THD *thd, const char *table_name,
7346
 
                         HA_CREATE_INFO *create_info)
 
7348
/**
 
7349
  @brief Check if the table can be created in the specified storage engine.
 
7350
 
 
7351
  Checks if the storage engine is enabled and supports the given table
 
7352
  type (e.g. normal, temporary, system). May do engine substitution
 
7353
  if the requested engine is disabled.
 
7354
 
 
7355
  @param thd          Thread descriptor.
 
7356
  @param db_name      Database name.
 
7357
  @param table_name   Name of table to be created.
 
7358
  @param create_info  Create info from parser, including engine.
 
7359
 
 
7360
  @retval true  Engine not available/supported, error has been reported.
 
7361
  @retval false Engine available/supported.
 
7362
*/
 
7363
static bool check_engine(THD *thd, const char *db_name,
 
7364
                         const char *table_name, HA_CREATE_INFO *create_info)
7347
7365
{
 
7366
  DBUG_ENTER("check_engine");
7348
7367
  handlerton **new_engine= &create_info->db_type;
7349
7368
  handlerton *req_engine= *new_engine;
7350
7369
  bool no_substitution=
7351
7370
        test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
7352
7371
  if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
7353
7372
                                  no_substitution, 1)))
7354
 
    return TRUE;
 
7373
    DBUG_RETURN(true);
7355
7374
 
7356
7375
  if (req_engine && req_engine != *new_engine)
7357
7376
  {
7369
7388
      my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
7370
7389
               ha_resolve_storage_engine_name(*new_engine), "TEMPORARY");
7371
7390
      *new_engine= 0;
7372
 
      return TRUE;
 
7391
      DBUG_RETURN(true);
7373
7392
    }
7374
7393
    *new_engine= myisam_hton;
7375
7394
  }
7376
 
  return FALSE;
 
7395
 
 
7396
  /*
 
7397
    Check, if the given table name is system table, and if the storage engine 
 
7398
    does supports it.
 
7399
  */
 
7400
  if ((create_info->used_fields & HA_CREATE_USED_ENGINE) &&
 
7401
      !ha_check_if_supported_system_table(*new_engine, db_name, table_name))
 
7402
  {
 
7403
    my_error(ER_UNSUPPORTED_ENGINE, MYF(0),
 
7404
             ha_resolve_storage_engine_name(*new_engine), db_name, table_name);
 
7405
    *new_engine= NULL;
 
7406
    DBUG_RETURN(true);
 
7407
  }
 
7408
 
 
7409
  DBUG_RETURN(false);
7377
7410
}