Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking view feature implement #8520

Closed
17 of 19 tasks
AndrewDi opened this issue Nov 29, 2018 · 6 comments
Closed
17 of 19 tasks

Tracking view feature implement #8520

AndrewDi opened this issue Nov 29, 2018 · 6 comments
Assignees
Labels
sig/planner SIG: Planner

Comments

@AndrewDi
Copy link
Contributor

AndrewDi commented Nov 29, 2018

This issue is to track view feature implement. proposal is from #8416 .

CREATE VIEW

DROP VIEW

SHOW TABLE STATUS

  • add func to support show view status

SELECT FROM VIEW

SHOW FULL TABLS

DESCRIBE TABLE

SHOW CREATE TABLE

Information Schema

ALTER TABLE

@morgo
Copy link
Contributor

morgo commented Dec 29, 2018

Can I help you with the infoschema implementation? I can see two issues:

  1. make information_schema.tables show table_type, comment as view. All remaining columns as NULL.
  2. add views to information_schema.views.

@AndrewDi
Copy link
Contributor Author

Can I help you with the infoschema implementation? I can see two issues:

  1. make information_schema.tables show table_type, comment as view. All remaining columns as NULL.
  2. add views to information_schema.views.

@morgo Sure, Do you check validity of view during select from information_schema.views and information_schema.tables?

@morgo
Copy link
Contributor

morgo commented Dec 30, 2018

@AndrewDi I don't think so. Two things to mention though:

  • The mysql server itself did not have view dependency tracking until MySQL 8.0. So we are 100% compatible to have views that will not work when queried.
  • I know of this issue where metadata could have been created that is broken. But I think these should only be corrected/handled on read if there was a persistent data bug in a GA version.

I will create an issue to support information_schema.

@AndrewDi
Copy link
Contributor Author

@morgo I have do some test on MySQL 5.7, and it seems like already have view dependency tracking?

mysql> create table t1(a int,b int);
Query OK, 0 rows affected (0.45 sec)

mysql> create view v as select * from t1;
Query OK, 0 rows affected (0.06 sec)

mysql> drop table t1;
Query OK, 0 rows affected (0.20 sec)

mysql> select * from information_schema.views where table_schema='test';
+---------------+--------------+------------+-----------------------------------------------------------------------+--------------+--------------+----------------+---------------+----------------------+----------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | VIEW_DEFINITION                                                       | CHECK_OPTION | IS_UPDATABLE | DEFINER        | SECURITY_TYPE | CHARACTER_SET_CLIENT | COLLATION_CONNECTION |
+---------------+--------------+------------+-----------------------------------------------------------------------+--------------+--------------+----------------+---------------+----------------------+----------------------+
| def           | test         | v          | select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` | NONE         |              | root@localhost | DEFINER       | latin1               | latin1_swedish_ci    |
+---------------+--------------+------------+-----------------------------------------------------------------------+--------------+--------------+----------------+---------------+----------------------+----------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                  |
+---------+------+--------------------------------------------------------------------------------------------------------------------------+
| Warning | 1356 | View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
+---------+------+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

MySQL Version:

root@2835f3d7b299:/# mysql -V
mysql  Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using  EditLine wrapper

@morgo
Copy link
Contributor

morgo commented Dec 30, 2018

@AndrewDi interesting behavior! I think this is the equivalent of running CHECK TABLE on each view. Since TiDB does not support CHECK TABLE, I think we should leave this to do later.

The 8.0 feature I was referring to is I_S.VIEW_TABLE_USAGE. You can find more info by searching for "information schema" within this page.

EDIT: Here is an example from MySQL 5.7 w/CHECK TABLE:

create table t1 (a int);
create view v1 as select * from t1;
drop table t1;
check table v1;

+---------+-------+----------+---------------------------------------------------------------------------------------------------------------------------+
| Table   | Op    | Msg_type | Msg_text                                                                                                                  |
+---------+-------+----------+---------------------------------------------------------------------------------------------------------------------------+
| test.v1 | check | Error    | Table 'test.t1' doesn't exist                                                                                             |
| test.v1 | check | Error    | View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| test.v1 | check | error    | Corrupt                                                                                                                   |
+---------+-------+----------+---------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

@AndrewDi
Copy link
Contributor Author

@morgo I'm agree with your idea, we could leave view check unimplement here. @XuHuaiyu

@zz-jason zz-jason added the sig/planner SIG: Planner label Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner
Projects
None yet
Development

No branches or pull requests

4 participants