mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
sending right error message where VIEW is not expected (BUG#4606)
This commit is contained in:
@ -38,6 +38,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
|
||||
static void free_cache_entry(TABLE *entry);
|
||||
static void mysql_rm_tmp_tables(void);
|
||||
static my_bool open_new_frm(const char *path, const char *alias,
|
||||
const char *db, const char *table_name,
|
||||
uint db_stat, uint prgflag,
|
||||
uint ha_open_flags, TABLE *outparam,
|
||||
TABLE_LIST *table_desc, MEM_ROOT *mem_root);
|
||||
@ -1379,8 +1380,6 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
|
||||
{
|
||||
char path[FN_REFLEN];
|
||||
int error;
|
||||
// we support new format only is have all parameters for it
|
||||
uint new_frm_flag= (table_desc && mem_root) ? NO_ERR_ON_NEW_FRM : 0;
|
||||
uint discover_retry_count= 0;
|
||||
DBUG_ENTER("open_unireg_entry");
|
||||
|
||||
@ -1388,12 +1387,12 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
|
||||
while ((error= openfrm(path, alias,
|
||||
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
|
||||
HA_GET_INDEX | HA_TRY_READ_ONLY |
|
||||
new_frm_flag),
|
||||
NO_ERR_ON_NEW_FRM),
|
||||
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
|
||||
thd->open_options, entry)) &&
|
||||
(error != 5 ||
|
||||
fn_format(path, path, 0, reg_ext, MY_UNPACK_FILENAME),
|
||||
open_new_frm(path, alias,
|
||||
open_new_frm(path, alias, db, name,
|
||||
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
|
||||
HA_GET_INDEX | HA_TRY_READ_ONLY),
|
||||
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
|
||||
@ -1679,6 +1678,8 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
|
||||
|
||||
thd->proc_info="Opening table";
|
||||
thd->current_tablenr= 0;
|
||||
/* open_ltable can be used only for BASIC TABLEs */
|
||||
table_list->required_type= FRMTYPE_TABLE;
|
||||
while (!(table= open_table(thd, table_list, 0, &refresh)) && refresh) ;
|
||||
|
||||
if (table)
|
||||
@ -3209,6 +3210,8 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
|
||||
open_new_frm()
|
||||
path path to .frm
|
||||
alias alias for table
|
||||
db database
|
||||
table_name name of table
|
||||
db_stat open flags (for example HA_OPEN_KEYFILE|HA_OPEN_RNDFILE..)
|
||||
can be 0 (example in ha_example_table)
|
||||
prgflag READ_ALL etc..
|
||||
@ -3218,7 +3221,9 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
|
||||
mem_root temporary MEM_ROOT for parsing
|
||||
*/
|
||||
static my_bool
|
||||
open_new_frm(const char *path, const char *alias, uint db_stat, uint prgflag,
|
||||
open_new_frm(const char *path, const char *alias,
|
||||
const char *db, const char *table_name,
|
||||
uint db_stat, uint prgflag,
|
||||
uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
|
||||
MEM_ROOT *mem_root)
|
||||
{
|
||||
@ -3226,28 +3231,36 @@ open_new_frm(const char *path, const char *alias, uint db_stat, uint prgflag,
|
||||
LEX_STRING pathstr;
|
||||
pathstr.str= (char *)path;
|
||||
pathstr.length= strlen(path);
|
||||
|
||||
if (!mem_root)
|
||||
mem_root= ¤t_thd->mem_root;
|
||||
|
||||
File_parser *parser= sql_parse_prepare(&pathstr, mem_root, 1);
|
||||
if (parser)
|
||||
{
|
||||
if (!strncmp("VIEW", parser->type()->str, parser->type()->length))
|
||||
{
|
||||
if (mysql_make_view(parser, table_desc))
|
||||
if (table_desc == 0 || table_desc->required_type == FRMTYPE_TABLE)
|
||||
{
|
||||
bzero(outparam, sizeof(*outparam)); // do not run repair
|
||||
DBUG_RETURN(1);
|
||||
my_error(ER_WRONG_OBJECT, MYF(0), db, table_name, "BASIC TABLE");
|
||||
goto err;
|
||||
}
|
||||
if (mysql_make_view(parser, table_desc))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* only VIEWs are supported now */
|
||||
my_error(ER_FRM_UNKNOWN_TYPE, MYF(0), path, parser->type()->str);
|
||||
bzero(outparam, sizeof(outparam)); // do not run repair
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
goto err;
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
bzero(outparam, sizeof(TABLE)); // do not run repair
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user