-
Notifications
You must be signed in to change notification settings - Fork 2.8k
console: support materialized views #4204
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
Conversation
This comment has been minimized.
This comment has been minimized.
|
An update on this: I had used the definition of I pushed a new commit that rewrites the query, based on how it was defined in posgres 9.5, which is the oldest version we support. I stripped some of the fields that either had no information (as in: they were declared as Importantly, this is still a WORK IN PROGRESS. I am currently running all cypress tests on versions 12 and 10, and will perform some additional manual ones / will add cypress tests for materialized views. |
This comment has been minimized.
This comment has been minimized.
f0305c1 to
7e82f37
Compare
This comment has been minimized.
This comment has been minimized.
7e82f37 to
a9e9b7b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
db2d4c9 to
f4e917e
Compare
This comment has been minimized.
This comment has been minimized.
9d340a5 to
64af004
Compare
This comment has been minimized.
This comment has been minimized.
64af004 to
3230392
Compare
This comment has been minimized.
This comment has been minimized.
|
Review app for commit acb8467 deployed to Heroku: https://hge-ci-pull-4204.herokuapp.com |
acb8467 to
490b8a0
Compare
Instead of sticking to the information_schema tables, this now uses pg internals. This is not a regression, as the query was already relying on some of them. Furthermore, this heavily simplifies the comment subqueries, since we have access to the oid.
This is horribly verbose; but it does the job. The giant expression of `isc` is almost exactly the definition of the `information_schema.columns` view, with one major restriction: it also list columns present in materialized views. This is very ugly and could be simplified heavily. For technical details: I obtained the details of the view by running `psql -E` and using `\dS+ information_schema.columns`. The only difference is this: before: `c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'p'::"char"])` after: `c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'm'::"char"])`
To be more precise: I have used the definition of `information_schema.columns` as it was in [version 9.5](https://github.com/postgres/postgres/blob/REL9_5_STABLE/src/backend/catalog/information_schema.sql), which is the oldest version we support. I tested it on my local database, which is on version 12. To make sure it worked, I had to remove several functions call that did not exist anymore. The result is a trimmed-down version, that has only the most essential fields. I am going to run more tests to see whether this is enough or not.
490b8a0 to
7fb9bdb
Compare
|
Review app for commit 7fb9bdb deployed to Heroku: https://hge-ci-pull-4204.herokuapp.com |
|
Sorry for the noise on this PR: I was blocked by what turned out to be #4250. I'll close this PR and open a new one when I have something a bit cleaner. |
|
Review app https://hge-ci-pull-4204.herokuapp.com is deleted |
Description
This is the frontend part of #91. WARNING: it is an ugly workaround!
The problem is as follows: this query used
information_schemato retrieve information about the underlying postgres database. Unfortunately, neitherinformation_schema.tablesnorinformation_schema.columnscontain data about materialized views. What this PR does is to change the query to instead rely on postgres internals, such aspg_classandpg_attribute. It has a few upsides; notably, retrieving comments is much easier now, since we have access to the oid of each element, and we can just usecol_descriptionandobj_description.However, the previous version of that query returned every single column of the
columnsview, unmodified. To emulate that behaviour, I had to recreate the entirecolumnsview in the query, while fixing it so that it includes materialized views.I obtained the definition of
columnsby runningpsql -Eand running\dS+ information_schema.columns. The only change is as follows:before:
c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'p'::"char"])after:
c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'm'::"char"])Affected components
Limitations, known bugs & workarounds
There are several things that are missing from this PR, in its current state:
view_infopart of the query is computed using theinformation_schema.viewsview, which... suffers from the exact same problem: not listing materialized views. I am not sure whether we actually want to treat them as views as far as the console is concerned, but that's something to check,MATERIALIZED VIEWtable type everywhere; from my limited testing, it treats is as a view (the name is italicized for instance),Ideally, this would be rewritten to call a backend function, and none of the postgres internals would be in the frontend. But in recent discussions we have agreed that it was preferable to do this workaround before doing the necessary server work.