[MDEV-32621] Identify invalid view/procedures/functions Created: 2022-08-23 Updated: 2024-01-19 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Critical |
| Reporter: | Muhammad Irfan | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is request to add feature to identify invalid objects like views, procedures etc. Note that invalid views can be identified with: select * from information_schema.tables where table_schema not in ('INFORMATION_SCHEMA','performance_schema','mysql','sys') and table_type='VIEW' and table_comment like '%invalid%'; |
| Comments |
| Comment by Daniel Black [ 2023-09-20 ] | |||||||||||||||||||||||
|
Wasn't this complete with | |||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-10-29 ] | |||||||||||||||||||||||
|
We cannot either user 'prepare stmt from call procedure_name' for this either as the stored procedure is not loaded or evaluated until the first execution of the statement. To solve this, we probably have to add a new server command where we would only analyze the stored procedure/view and check if it is correct. CHECK VIEW ... This cannot easily be done with a tool, so I am changing this issue to an MDEV | |||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-10-31 ] | |||||||||||||||||||||||
|
Alternatively, we can implement standard %_%_USAGE tables from the INFORMATION_SCHEMA. Like INFORMATION_SCHEMA.ROUTINE_TABLE_USAGE table that shows all tables a particular routine uses. It could mark non-existing tables or emit warnings for them. | |||||||||||||||||||||||
| Comment by Ralf Gebhardt [ 2023-11-01 ] | |||||||||||||||||||||||
|
Implementing a usage table with routine_catalog, routine_schema, routine_name, table_catalog, table_schema, table_name looks to me to be a good solution. PostreSQL is also providing them | |||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-11-01 ] | |||||||||||||||||||||||
|
For completeness, this is a full list of standard _USAGE views:
For the purpose of this task it's tempting to implement all ROUTINE_ views, but selecting them all to find missing objects would be rather inefficient, as they all will go through all rows in mysql.proc, parse and compile stored routines, etc. It would be better if all of these views would print warnings for missing objects in routines, then it'll be enough to select from one of these views to get the complete list. Let's try to do that. Meaning, it'll be enough to implement just one view, let's say, ROUTINE_COLUMN_USAGE. |