diff options
-rw-r--r-- | mysql-test/suite/versioning/r/view.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/view.test | 3 | ||||
-rw-r--r-- | sql/sql_view.cc | 21 |
3 files changed, 22 insertions, 4 deletions
diff --git a/mysql-test/suite/versioning/r/view.result b/mysql-test/suite/versioning/r/view.result index 0406f47cf3b..4dc6455e7ab 100644 --- a/mysql-test/suite/versioning/r/view.result +++ b/mysql-test/suite/versioning/r/view.result @@ -110,6 +110,8 @@ x 1 select * from vvvt1 for system_time all; x +create or replace table t1 (x int) with system versioning; +create or replace view vt1(c) as select x from t1; drop view vvvt1; drop view vvt1; drop view vt1; diff --git a/mysql-test/suite/versioning/t/view.test b/mysql-test/suite/versioning/t/view.test index 1ed487fec44..909e55eac82 100644 --- a/mysql-test/suite/versioning/t/view.test +++ b/mysql-test/suite/versioning/t/view.test @@ -70,6 +70,9 @@ select * from vt1 for system_time all; select * from vvt1 for system_time all; select * from vvvt1 for system_time all; +create or replace table t1 (x int) with system versioning; +create or replace view vt1(c) as select x from t1; + drop view vvvt1; drop view vvt1; drop view vt1; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 8ee4a75e259..215d81f5724 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -463,12 +463,25 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, TABLE_SHARE *s= tl->table->s; if (s->versioned) { + const char *start= s->vers_start_field()->field_name; + const char *end = s->vers_end_field()->field_name; + select_lex->item_list.push_back(new (thd->mem_root) Item_field( - thd, &select_lex->context, NULL, NULL, - s->vers_start_field()->field_name)); + thd, &select_lex->context, NULL, NULL, start)); select_lex->item_list.push_back(new (thd->mem_root) Item_field( - thd, &select_lex->context, NULL, NULL, - s->vers_end_field()->field_name)); + thd, &select_lex->context, NULL, NULL, end)); + + if (lex->view_list.elements) + { + if (LEX_STRING *s= thd->make_lex_string(start, strlen(start))) + lex->view_list.push_back(s); + else + goto err; + if (LEX_STRING *s= thd->make_lex_string(end, strlen(end))) + lex->view_list.push_back(s); + else + goto err; + } } } } |