Below is the list of changes that have just been committed into a local
5.0 repository of georg. When georg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1977 05/09/19 05:32:38 georg@stripped +3 -0
Merge grichter@stripped:/home/bk/mysql-5.0
into lmy002.wdf.sap.corp:/home/georg/work/mysql/bugs/mysql-5.0-master
sql/sql_view.cc
1.65 05/09/19 05:32:35 georg@stripped +0 -0
Auto merged
mysql-test/t/view.test
1.110 05/09/19 05:32:35 georg@stripped +0 -0
Auto merged
mysql-test/r/view.result
1.119 05/09/19 05:32:35 georg@stripped +0 -0
Auto merged
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: georg
# Host: lmy002.wdf.sap.corp
# Root: /home/georg/work/mysql/bugs/mysql-5.0-master/RESYNC
--- 1.118/mysql-test/r/view.result 2005-09-15 18:50:09 +02:00
+++ 1.119/mysql-test/r/view.result 2005-09-19 05:32:35 +02:00
@@ -845,6 +845,15 @@
cast(1 as char(3))
1
drop view v1;
+create table t1 (a int);
+create view v1 as select a from t1;
+create database seconddb;
+rename table v1 to seconddb.v1;
+ERROR HY000: Changing schema from 'test' to 'seconddb' is not allowed.
+rename table v1 to v2;
+drop table t1;
+drop view v2;
+drop database seconddb;
create view v1 as select 'a',1;
create view v2 as select * from v1 union all select * from v1;
create view v3 as select * from v2 where 1 = (select `1` from v2);
--- 1.109/mysql-test/t/view.test 2005-09-15 18:50:09 +02:00
+++ 1.110/mysql-test/t/view.test 2005-09-19 05:32:35 +02:00
@@ -786,6 +786,19 @@
drop view v1;
#
+# renaming views
+#
+create table t1 (a int);
+create view v1 as select a from t1;
+create database seconddb;
+-- error 1450
+rename table v1 to seconddb.v1;
+rename table v1 to v2;
+drop table t1;
+drop view v2;
+drop database seconddb;
+
+#
# bug handling from VIEWs
#
create view v1 as select 'a',1;
--- 1.64/sql/sql_view.cc 2005-09-14 22:06:39 +02:00
+++ 1.65/sql/sql_view.cc 2005-09-19 05:32:35 +02:00
@@ -479,8 +479,12 @@
/* index of revision number in following table */
static const int revision_number_position= 8;
+/* index of source */
+static const int source_number_position= 11;
/* index of last required parameter for making view */
static const int required_view_parameters= 10;
+/* number of backups */
+static const int num_view_backups= 3;
/*
table of VIEW .frm field descriptors
@@ -708,7 +712,7 @@
}
if (sql_create_definition_file(&dir, &file, view_file_type,
- (gptr)view, view_parameters, 3))
+ (gptr)view, view_parameters, num_view_backups))
{
DBUG_RETURN(thd->net.report_error? -1 : 1);
}
@@ -1165,7 +1169,7 @@
int length;
DBUG_ENTER("mysql_frm_type");
- if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(MY_WME))) < 0)
+ if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0)
{
DBUG_RETURN(FRMTYPE_ERROR);
}
@@ -1368,4 +1372,78 @@
return (strncmp(md5, view->md5.str, 32) ?
HA_ADMIN_WRONG_CHECKSUM :
HA_ADMIN_OK);
+}
+
+/*
+ rename view
+
+ Synopsis:
+ renames a view
+
+ Parameters:
+ thd thread handler
+ new_name new name of view
+ view view
+
+ Return values:
+ FALSE Ok
+ TRUE Error
+*/
+bool
+mysql_rename_view(THD *thd,
+ const char *new_name,
+ TABLE_LIST *view)
+{
+ LEX_STRING pathstr, file;
+ File_parser *parser;
+ char view_path[FN_REFLEN];
+
+ DBUG_ENTER("mysql_rename_view");
+
+ strxnmov(view_path, FN_REFLEN, mysql_data_home, "/", view->db, "/",
+ view->table_name, reg_ext, NullS);
+ (void) unpack_filename(view_path, view_path);
+
+ pathstr.str= (char *)view_path;
+ pathstr.length= strlen(view_path);
+
+ if ((parser= sql_parse_prepare(&pathstr, thd->mem_root, 1)) &&
+ is_equal(&view_type, parser->type())) {
+ char dir_buff[FN_REFLEN], file_buff[FN_REFLEN];
+
+ /* get view definition and source */
+ if (mysql_make_view(parser, view) ||
+ parser->parse((gptr)view, thd->mem_root,
+ view_parameters + source_number_position, 1))
+ DBUG_RETURN(1);
+
+ /* rename view and it's backups */
+ if (rename_in_schema_file(view->db, view->table_name, new_name,
+ view->revision - 1, num_view_backups))
+ DBUG_RETURN(1);
+
+ strxnmov(dir_buff, FN_REFLEN, mysql_data_home, "/", view->db, "/", NullS);
+ (void) unpack_filename(dir_buff, dir_buff);
+
+ pathstr.str= (char*)dir_buff;
+ pathstr.length= strlen(dir_buff);
+
+ file.str= file_buff;
+ file.length= (strxnmov(file_buff, FN_REFLEN, new_name, reg_ext, NullS)
+ - file_buff);
+
+ if (sql_create_definition_file(&pathstr, &file, view_file_type,
+ (gptr)view, view_parameters, num_view_backups)) {
+ /* restore renamed view in case of error */
+ rename_in_schema_file(view->db, new_name, view->table_name,
+ view->revision - 1, num_view_backups);
+ DBUG_RETURN(1);
+ }
+ } else
+ DBUG_RETURN(1);
+
+ /* remove cache entries */
+ query_cache_invalidate3(thd, view, 0);
+ sp_cache_invalidate();
+ DBUG_RETURN(0);
}
| Thread |
|---|
| • bk commit into 5.0 tree (georg:1.1977) | Georg Richter | 19 Sep |