diff options
author | unknown <evgen@sunlight.local> | 2006-08-09 02:49:29 +0400 |
---|---|---|
committer | unknown <evgen@sunlight.local> | 2006-08-09 02:49:29 +0400 |
commit | 68d265154ee02a2305537699054e5874b5e0fc4a (patch) | |
tree | d3677af0311c695e32ef6490310663287f0f2054 /sql | |
parent | b6897efbb8b7119e4abd28bed93a3579c2bf914e (diff) | |
parent | 1e9ebd010a6b6c7a078d0caa13f9c8145dec1d50 (diff) | |
download | mariadb-git-68d265154ee02a2305537699054e5874b5e0fc4a.tar.gz |
Merge sunlight.local:/local_work/leak_fix_orig
into sunlight.local:/local_work/leak_fix-5.1-mysql
sql/sql_lex.h:
Auto merged
sql/sql_view.cc:
Auto merged
sql/sql_view.h:
Auto merged
sql/unireg.h:
Auto merged
sql/sql_base.cc:
Manual merge
sql/table.cc:
Manual merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 34 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_view.cc | 11 | ||||
-rw-r--r-- | sql/sql_view.h | 3 | ||||
-rw-r--r-- | sql/table.cc | 3 | ||||
-rw-r--r-- | sql/unireg.h | 3 |
6 files changed, 38 insertions, 18 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e40b9721911..c1464e10f63 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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 diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 55dc6cb55a4..192b6c75f24 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -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(); }; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 09a199b2738..201725301d6 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -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, ¬_used, 0) && + if (!open_table(thd, &decoy, thd->mem_root, ¬_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 diff --git a/sql/sql_view.h b/sql/sql_view.h index 1e3e5f4aa73..7e54d57cfdf 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -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); diff --git a/sql/table.cc b/sql/table.cc index 71d4f8df837..18eb6d62c5c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -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) { diff --git a/sql/unireg.h b/sql/unireg.h index 9ab8753af84..af91793e8fe 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -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 |