diff options
author | unknown <bell@sanja.is.com.ua> | 2004-09-24 12:50:10 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-09-24 12:50:10 +0300 |
commit | 66b4c82eac38fb2acc1f3f5e635f496c8b1c6a9a (patch) | |
tree | 085167e02e69de92b0e1c744cb9f87a33b2e0c76 /sql | |
parent | 79ffe4f504617693408ce717aad357cc09fbab4b (diff) | |
download | mariadb-git-66b4c82eac38fb2acc1f3f5e635f496c8b1c6a9a.tar.gz |
new show create view output
mysqldump view support (BUG#4972)
workaround to allow view work after LOCK TABLES
client/mysqldump.c:
view support
mysql-test/r/lowercase_view.result:
new show create view output
mysql-test/r/view.result:
new show create view output
test of locked views
mysql-test/t/view.test:
new show create view output
test of locked views
sql/sql_base.cc:
workaround to allow view work after LOCK TABLES
sql/sql_show.cc:
new show create view output (to help mysql dump detect views)
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 30 | ||||
-rw-r--r-- | sql/sql_show.cc | 18 |
2 files changed, 44 insertions, 4 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8587942e30e..e7c2cfe3534 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -906,6 +906,36 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, goto reset; } } + /* + is it view? + (it is work around to allow to open view with locked tables, + real fix will be made after definition cache will be made) + */ + { + char path[FN_REFLEN]; + strxnmov(path, FN_REFLEN, mysql_data_home, "/", table_list->db, "/", + table_list->real_name, reg_ext, NullS); + (void) unpack_filename(path, path); + if (mysql_frm_type(path) == FRMTYPE_VIEW) + { + VOID(pthread_mutex_lock(&LOCK_open)); + if (open_unireg_entry(thd, table, table_list->db, + table_list->real_name, + alias, table_list, mem_root)) + { + table->next=table->prev=table; + free_cache_entry(table); + } + else + { + DBUG_ASSERT(table_list->view); + my_free((gptr)table, MYF(0)); + VOID(pthread_mutex_unlock(&LOCK_open)); + DBUG_RETURN(0); // VIEW + } + VOID(pthread_mutex_unlock(&LOCK_open)); + } + } my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias); DBUG_RETURN(0); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1209be6ac1d..49e2c244d32 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -879,6 +879,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) table_list->real_name, "VIEW"); DBUG_RETURN(-1); } + table= table_list->table; if ((table_list->view ? @@ -887,10 +888,19 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) DBUG_RETURN(-1); List<Item> field_list; - field_list.push_back(new Item_empty_string("Table",NAME_LEN)); - // 1024 is for not to confuse old clients - field_list.push_back(new Item_empty_string("Create Table", - max(buffer.length(),1024))); + if (table_list->view) + { + field_list.push_back(new Item_empty_string("View",NAME_LEN)); + field_list.push_back(new Item_empty_string("Create View", + max(buffer.length(),1024))); + } + else + { + field_list.push_back(new Item_empty_string("Table",NAME_LEN)); + // 1024 is for not to confuse old clients + field_list.push_back(new Item_empty_string("Create Table", + max(buffer.length(),1024))); + } if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) |