Commit 0d699601 authored by evgen@sunlight.local's avatar evgen@sunlight.local

Merge sunlight.local:/local_work/leak_fix_orig

into  sunlight.local:/local_work/leak_fix-5.1-mysql
parents 21f7f347 1250b06a
......@@ -39,7 +39,7 @@ static bool table_def_inited= 0;
static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
const char *alias,
char *cache_key, uint cache_key_length,
MEM_ROOT *mem_root);
MEM_ROOT *mem_root, uint flags);
static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void);
static bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
......@@ -1763,7 +1763,7 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list)
if (open_unireg_entry(thd, table, table_list, table_name,
table->s->table_cache_key.str,
table->s->table_cache_key.length, thd->mem_root))
table->s->table_cache_key.length, thd->mem_root, 0))
{
intern_close_table(table);
/*
......@@ -1960,7 +1960,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table= &tab;
VOID(pthread_mutex_lock(&LOCK_open));
if (!open_unireg_entry(thd, table, table_list, alias,
key, key_length, mem_root))
key, key_length, mem_root, 0))
{
DBUG_ASSERT(table_list->view != 0);
VOID(pthread_mutex_unlock(&LOCK_open));
......@@ -2044,6 +2044,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
}
else
{
int error;
/* Free cache if too big */
while (open_cache.records > table_cache_size && unused_tables)
VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */
......@@ -2055,15 +2056,23 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
DBUG_RETURN(NULL);
}
if (open_unireg_entry(thd, table, table_list, alias, key, key_length,
mem_root))
error= open_unireg_entry(thd, table, table_list, alias, key, key_length,
mem_root, (flags & OPEN_VIEW_NO_PARSE));
if (error > 0)
{
my_free((gptr)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(NULL);
}
if (table_list->view)
if (table_list->view || error < 0)
{
/*
VIEW not really opened, only frm were read.
Set 1 as a flag here
*/
if (error < 0)
table_list->view= (st_lex*)1;
my_free((gptr)table, MYF(0));
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(0); // VIEW
......@@ -2165,7 +2174,6 @@ static bool reopen_table(TABLE *table)
sql_print_error("Table %s had a open data handler in reopen_table",
table->alias);
#endif
table_list.db= table->s->db.str;
table_list.table_name= table->s->table_name.str;
table_list.table= table;
......@@ -2179,7 +2187,7 @@ static bool reopen_table(TABLE *table)
table->alias,
table->s->table_cache_key.str,
table->s->table_cache_key.length,
thd->mem_root))
thd->mem_root, 0))
goto end;
/* This list copies variables set by open_table */
......@@ -2613,6 +2621,8 @@ void assign_new_table_id(TABLE_SHARE *share)
cache_key Key for share_cache
cache_key_length length of cache_key
mem_root temporary mem_root for parsing
flags the OPEN_VIEW_NO_PARSE flag to be passed to
openfrm()/open_new_frm()
NOTES
Extra argument for open is taken from thd->open_options
......@@ -2626,7 +2636,7 @@ void assign_new_table_id(TABLE_SHARE *share)
static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
const char *alias,
char *cache_key, uint cache_key_length,
MEM_ROOT *mem_root)
MEM_ROOT *mem_root, uint flags)
{
int error;
TABLE_SHARE *share;
......@@ -2649,7 +2659,7 @@ retry:
HA_GET_INDEX | HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
thd->open_options, entry, table_list,
mem_root);
mem_root, (flags & OPEN_VIEW_NO_PARSE)));
if (error)
goto err;
/* TODO: Don't free this */
......@@ -2707,7 +2717,6 @@ retry:
}
if (!entry->s || !entry->s->crashed)
goto err;
// Code below is for repairing a crashed file
if ((error= lock_table_name(thd, table_list, TRUE)))
{
......@@ -6339,7 +6348,8 @@ open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
"BASE TABLE");
goto err;
}
if (mysql_make_view(thd, parser, table_desc))
if (mysql_make_view(thd, parser, table_desc,
(prgflag & OPEN_VIEW_NO_PARSE)))
goto err;
}
else
......
......@@ -402,7 +402,7 @@ public:
friend class st_select_lex_unit;
friend bool mysql_new_select(struct st_lex *lex, bool move_down);
friend bool mysql_make_view(THD *thd, File_parser *parser,
TABLE_LIST *table);
TABLE_LIST *table, uint flags);
private:
void fast_exclude();
};
......
......@@ -183,7 +183,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view)
TABLE_LIST decoy;
memcpy (&decoy, view, sizeof (TABLE_LIST));
if (!open_table(thd, &decoy, thd->mem_root, &not_used, 0) &&
if (!open_table(thd, &decoy, thd->mem_root, &not_used, OPEN_VIEW_NO_PARSE) &&
!decoy.view)
{
return TRUE;
......@@ -817,13 +817,14 @@ loop_out:
thd Thread handler
parser parser object
table TABLE_LIST structure for filling
flags flags
RETURN
0 ok
1 error
*/
bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
uint flags)
{
SELECT_LEX *end, *view_select;
LEX *old_lex, *lex;
......@@ -914,6 +915,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
table->db, table->table_name);
get_default_definer(thd, &table->definer);
}
if (flags & OPEN_VIEW_NO_PARSE)
{
DBUG_RETURN(FALSE);
}
/*
Save VIEW parameters, which will be wiped out by derived table
......
......@@ -19,7 +19,8 @@
bool mysql_create_view(THD *thd,
enum_view_create_mode mode);
bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table);
bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
uint flags);
bool mysql_drop_view(THD *thd, TABLE_LIST *view, enum_drop_mode drop_mode);
......
......@@ -353,6 +353,9 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags)
else
goto err;
if (prgflag & OPEN_VIEW_NO_PARSE)
goto err;
/* No handling of text based files yet */
if (table_type == 1)
{
......
......@@ -151,7 +151,8 @@
#define READ_SCREENS 1024 /* Read screens, info and helpfile */
#define DELAYED_OPEN 4096 /* Open table later */
#define OPEN_VIEW 8192 /* Allow open on view */
#define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view,
but do not parse view itself */
#define SC_INFO_LENGTH 4 /* Form format constant */
#define TE_INFO_LENGTH 3
#define MTYP_NOEMPTY_BIT 128
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment