console: support tracking partitioned tables (close #5071) (#5258)

This commit is contained in:
Aleksandra Sikora 2020-07-02 09:44:27 +02:00 committed by GitHub
parent 9ccbd1c0f6
commit af452de754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -10,6 +10,7 @@
- server: shrink libpq connection request/response buffers back to 1MB if they grow beyond 2MB, fixing leak-like behavior on active servers (#5087)
- server: disable prepared statements for mutations as we end up with single-use objects which result in excessive memory consumption for mutation heavy workloads (#5255)
- console: allow configuring statement timeout on console RawSQL page (close #4998) (#5045)
- console: support tracking partitioned tables (close #5071) (#5258)
- docs: add note for managed databases in postgres requirements (close #1677, #3783) (#5228)
- docs: add 1-click deployment to Nhost page to the deployment guides (#5180)
- docs: add hasura cloud to getting started section (close #5206) (#5208)

View File

@ -78,7 +78,12 @@ export const makeBaseTable = (
export interface Table extends BaseTable {
table_name: string;
table_schema: string;
table_type: string;
table_type:
| 'TABLE'
| 'VIEW'
| 'MATERIALIZED VIEW'
| 'FOREIGN TABLE'
| 'PARTITIONED TABLE';
is_table_tracked: boolean;
columns: TableColumn[];
relationships: TableRelationship[];
@ -178,7 +183,11 @@ export const getTableNameWithSchema = (
};
export const checkIfTable = (table: Table) => {
return table.table_type === 'TABLE';
return (
table.table_type === 'TABLE' ||
table.table_type === 'PARTITIONED TABLE' ||
table.table_type === 'FOREIGN TABLE'
);
};
export const displayTableName = (table: Table) => {

View File

@ -408,6 +408,7 @@ FROM (
when pgc.relkind = 'f' then 'FOREIGN TABLE'
when pgc.relkind = 'v' then 'VIEW'
when pgc.relkind = 'm' then 'MATERIALIZED VIEW'
when pgc.relkind = 'p' then 'PARTITIONED TABLE'
end as table_type,
obj_description(pgc.oid) AS comment,
COALESCE(json_agg(DISTINCT row_to_json(isc) :: jsonb || jsonb_build_object('comment', col_description(pga.attrelid, pga.attnum))) filter (WHERE isc.column_name IS NOT NULL), '[]' :: json) AS columns,
@ -454,7 +455,7 @@ FROM (
coalesce(bt.typname, t.typname) AS udt_name,
a.attnum AS dtd_identifier,
CASE WHEN c.relkind = 'r' OR
(c.relkind IN ('v', 'f') AND
(c.relkind IN ('v', 'f', 'p') AND
pg_column_is_updatable(c.oid, a.attnum, false))
THEN 'YES' ELSE 'NO' END AS is_updatable
FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
@ -465,7 +466,7 @@ FROM (
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
WHERE (NOT pg_is_other_temp_schema(nc.oid))
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'm', 'f')
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'm', 'f', 'p')
AND (pg_has_role(c.relowner, 'USAGE')
OR has_column_privilege(c.oid, a.attnum,
'SELECT, INSERT, UPDATE, REFERENCES'))
@ -514,7 +515,7 @@ FROM (
AND isv.table_name = pgc.relname
WHERE
pgc.relkind IN ('r', 'v', 'f', 'm')
pgc.relkind IN ('r', 'v', 'f', 'm', 'p')
${whereQuery}
GROUP BY pgc.oid, pgn.nspname, pgc.relname, table_type, isv.*
) AS info;