diff --git a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js index 6eeed9373..8eea10464 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js @@ -59,7 +59,7 @@ class Analyser extends DatabaseAnalyser { const query = super.createQuery(sql[resFileName], typeFields, replacements); return query; } - + async _computeSingleObjectId() { const { typeField, schemaName, pureName } = this.singleObjectFilter; this.singleObjectId = `${typeField}:${schemaName || 'public'}.${pureName}`; @@ -364,6 +364,10 @@ class Analyser extends DatabaseAnalyser { })), }; } + + getDefaultSchemaNameCondition() { + return `not in ('pg_catalog', 'pg_toast', 'information_schema')`; + } } module.exports = Analyser; diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/columns.js b/plugins/dbgate-plugin-postgres/src/backend/sql/columns.js index 6053e1ed3..55b761ede 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/columns.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/columns.js @@ -11,10 +11,7 @@ select column_default as "default_value" from information_schema.columns where - table_schema <> 'information_schema' - and table_schema <> 'pg_catalog' - and table_schema !~ '^pg_toast' - and table_schema !~ '^_timescaledb_' + table_schema !~ '^_timescaledb_' and ( ('tables:' || table_schema || '.' || table_name) =OBJECT_ID_CONDITION or diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/primaryKeys.js b/plugins/dbgate-plugin-postgres/src/backend/sql/primaryKeys.js index 05792ab34..bd0fb1b51 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/primaryKeys.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/primaryKeys.js @@ -8,10 +8,7 @@ select from information_schema.table_constraints inner join information_schema.key_column_usage on table_constraints.table_name = key_column_usage.table_name and table_constraints.constraint_name = key_column_usage.constraint_name where - table_constraints.table_schema <> 'information_schema' - and table_constraints.table_schema <> 'pg_catalog' - and table_constraints.table_schema !~ '^pg_toast' - and table_constraints.table_schema !~ '^_timescaledb_' + table_constraints.table_schema !~ '^_timescaledb_' and table_constraints.constraint_type = 'PRIMARY KEY' and ('tables:' || table_constraints.table_schema || '.' || table_constraints.table_name) =OBJECT_ID_CONDITION and table_constraints.table_schema =SCHEMA_NAME_CONDITION diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/routineModifications.js b/plugins/dbgate-plugin-postgres/src/backend/sql/routineModifications.js index 663d948bf..2b3433634 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/routineModifications.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/routineModifications.js @@ -5,6 +5,6 @@ select md5(routine_definition) as "hash_code", routine_type as "object_type" from - information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog' and routine_schema !~ '^_timescaledb_' + information_schema.routines where routine_schema !~ '^_timescaledb_' and routine_type in ('PROCEDURE', 'FUNCTION') and routine_schema =SCHEMA_NAME_CONDITION `; diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/routines.js b/plugins/dbgate-plugin-postgres/src/backend/sql/routines.js index aed4889fe..bf7015297 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/routines.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/routines.js @@ -8,7 +8,7 @@ select $typeAggFunc(data_type $typeAggParam) as "data_type", max(external_language) as "language" from - information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog' and routine_schema !~ '^_timescaledb_' + information_schema.routines where routine_schema !~ '^_timescaledb_' and routine_schema =SCHEMA_NAME_CONDITION and ( (routine_type = 'PROCEDURE' and ('procedures:' || routine_schema || '.' || routine_name) =OBJECT_ID_CONDITION) diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/tableList.js b/plugins/dbgate-plugin-postgres/src/backend/sql/tableList.js index e08ff01a5..9e9f2b735 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/tableList.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/tableList.js @@ -3,10 +3,7 @@ select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_ from information_schema.tables infoTables where infoTables.table_type not like '%VIEW%' and ('tables:' || infoTables.table_schema || '.' || infoTables.table_name) =OBJECT_ID_CONDITION -and infoTables.table_schema <> 'pg_catalog' -and infoTables.table_schema <> 'information_schema' and infoTables.table_schema <> 'pg_internal' -and infoTables.table_schema !~ '^pg_toast' and infoTables.table_schema !~ '^_timescaledb_' and infoTables.table_schema =SCHEMA_NAME_CONDITION `; diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/tableModifications.js b/plugins/dbgate-plugin-postgres/src/backend/sql/tableModifications.js index 8a70848f2..e26388b05 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/tableModifications.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/tableModifications.js @@ -21,10 +21,7 @@ select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_ from information_schema.tables infoTables where infoTables.table_type not like '%VIEW%' and ('tables:' || infoTables.table_schema || '.' || infoTables.table_name) =OBJECT_ID_CONDITION -and infoTables.table_schema <> 'pg_catalog' -and infoTables.table_schema <> 'information_schema' and infoTables.table_schema <> 'pg_internal' -and infoTables.table_schema !~ '^pg_toast' and infoTables.table_schema !~ '^_timescaledb_' and infoTables.table_schema =SCHEMA_NAME_CONDITION `; diff --git a/plugins/dbgate-plugin-postgres/src/backend/sql/views.js b/plugins/dbgate-plugin-postgres/src/backend/sql/views.js index 2ee21ae99..77e502ad4 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/sql/views.js +++ b/plugins/dbgate-plugin-postgres/src/backend/sql/views.js @@ -6,6 +6,6 @@ select md5(view_definition) as "hash_code" from information_schema.views -where table_schema != 'information_schema' and table_schema != 'pg_catalog' and table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION +where table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION and ('views:' || table_schema || '.' || table_name) =OBJECT_ID_CONDITION `;