mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 00:16:00 +00:00
postgresql materialized views #123
This commit is contained in:
@@ -2,11 +2,14 @@ const columns = require('./columns');
|
||||
const tableModifications = require('./tableModifications');
|
||||
const tableList = require('./tableList');
|
||||
const viewModifications = require('./viewModifications');
|
||||
const matviewModifications = require('./matviewModifications');
|
||||
const primaryKeys = require('./primaryKeys');
|
||||
const foreignKeys = require('./foreignKeys');
|
||||
const views = require('./views');
|
||||
const matviews = require('./matviews');
|
||||
const routines = require('./routines');
|
||||
const routineModifications = require('./routineModifications');
|
||||
const matviewColumns = require('./matviewColumns');
|
||||
|
||||
module.exports = {
|
||||
columns,
|
||||
@@ -18,4 +21,7 @@ module.exports = {
|
||||
views,
|
||||
routines,
|
||||
routineModifications,
|
||||
matviews,
|
||||
matviewModifications,
|
||||
matviewColumns,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = `
|
||||
SELECT pg_namespace.nspname AS "schema_name"
|
||||
, pg_class.relname AS "pure_name"
|
||||
, pg_attribute.attname AS "column_name"
|
||||
, pg_catalog.format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS "data_type"
|
||||
FROM pg_catalog.pg_class
|
||||
INNER JOIN pg_catalog.pg_namespace
|
||||
ON pg_class.relnamespace = pg_namespace.oid
|
||||
INNER JOIN pg_catalog.pg_attribute
|
||||
ON pg_class.oid = pg_attribute.attrelid
|
||||
-- Keeps only materialized views, and non-db/catalog/index columns
|
||||
WHERE pg_class.relkind = 'm'
|
||||
AND pg_attribute.attnum >= 1
|
||||
AND ('matviews:' || pg_namespace.nspname || '.' || pg_class.relname) =OBJECT_ID_CONDITION
|
||||
|
||||
ORDER BY pg_attribute.attnum
|
||||
`;
|
||||
@@ -0,0 +1,8 @@
|
||||
module.exports = `
|
||||
select
|
||||
matviewname as "pure_name",
|
||||
schemaname as "schema_name",
|
||||
md5(definition) as "hash_code"
|
||||
from
|
||||
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%'
|
||||
`;
|
||||
10
plugins/dbgate-plugin-postgres/src/backend/sql/matviews.js
Normal file
10
plugins/dbgate-plugin-postgres/src/backend/sql/matviews.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = `
|
||||
select
|
||||
matviewname as "pure_name",
|
||||
schemaname as "schema_name",
|
||||
definition as "definition",
|
||||
md5(definition) as "hash_code"
|
||||
from
|
||||
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%'
|
||||
and ('matviews:' || schemaname || '.' || matviewname) =OBJECT_ID_CONDITION
|
||||
`;
|
||||
Reference in New Issue
Block a user