Ensure that the 'Dbo' schema is displayed as a regular schema rather than a system catalog schema. #7061

This commit is contained in:
Akshay Joshi 2023-12-21 18:52:27 +05:30
parent 09b83e54a2
commit 9ccdaf73cd
11 changed files with 19 additions and 18 deletions

View File

@ -20,6 +20,7 @@ Bundled PostgreSQL Utilities
New features New features
************ ************
| `Issue #2483 <https://github.com/pgadmin-org/pgadmin4/issues/2483>`_ - Administer pgAdmin Users and Preferences Using the Command Line Interface (CLI).
| `Issue #5908 <https://github.com/pgadmin-org/pgadmin4/issues/5908>`_ - Allow users to convert View/Edit table into a Query tool to enable editing the SQL generated. | `Issue #5908 <https://github.com/pgadmin-org/pgadmin4/issues/5908>`_ - Allow users to convert View/Edit table into a Query tool to enable editing the SQL generated.
| `Issue #7016 <https://github.com/pgadmin-org/pgadmin4/issues/7016>`_ - Added keep-alive support for SSH sessions when connecting to a PostgreSQL server via an SSH tunnel. | `Issue #7016 <https://github.com/pgadmin-org/pgadmin4/issues/7016>`_ - Added keep-alive support for SSH sessions when connecting to a PostgreSQL server via an SSH tunnel.
@ -32,4 +33,6 @@ Bug fixes
| `Issue #6193 <https://github.com/pgadmin-org/pgadmin4/issues/6193>`_ - Fixed an issue where query tool title did not change after "Save As" until any new change is made. | `Issue #6193 <https://github.com/pgadmin-org/pgadmin4/issues/6193>`_ - Fixed an issue where query tool title did not change after "Save As" until any new change is made.
| `Issue #6781 <https://github.com/pgadmin-org/pgadmin4/issues/6781>`_ - Fixed an issue where export servers was not adding extension if not specified. | `Issue #6781 <https://github.com/pgadmin-org/pgadmin4/issues/6781>`_ - Fixed an issue where export servers was not adding extension if not specified.
| `Issue #6815 <https://github.com/pgadmin-org/pgadmin4/issues/6815>`_ - Fixed an issue where pgAdmin imports servers to the wrong accounts for the external authentication.
| `Issue #7061 <https://github.com/pgadmin-org/pgadmin4/issues/7061>`_ - Ensure that the 'Dbo' schema is displayed as a regular schema rather than a system catalog schema.
| `Issue #7070 <https://github.com/pgadmin-org/pgadmin4/issues/7070>`_ - Fixed an issue where pgAgent job schedule dialog is not opening for edit. | `Issue #7070 <https://github.com/pgadmin-org/pgadmin4/issues/7070>`_ - Fixed an issue where pgAgent job schedule dialog is not opening for edit.

View File

@ -49,9 +49,9 @@ class CatalogObjectModule(SchemaChildModule):
# Flag for not to show node under Schema/Catalog node # Flag for not to show node under Schema/Catalog node
# By default its set to True to display node in schema/catalog # By default its set to True to display node in schema/catalog
# We do not want to display 'Catalog Objects' under Schema/Catalog # We do not want to display 'Catalog Objects' under Schema/Catalog
# but only in information_schema/sys/dbo # but only in information_schema/sys
CATALOG_DB_SUPPORTED = False CATALOG_DB_SUPPORTED = False
SUPPORTED_SCHEMAS = ['information_schema', 'sys', 'dbo'] SUPPORTED_SCHEMAS = ['information_schema', 'sys']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """

View File

@ -1,5 +1,5 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_catalog.pg_namespace nsp FROM pg_catalog.pg_namespace nsp
WHERE nsp.oid={{scid}}::oid WHERE nsp.oid={{scid}}::oid
AND ( AND (

View File

@ -1,11 +1,11 @@
{% macro VALID_CATALOGS(server_type) -%} {% macro VALID_CATALOGS(server_type) -%}
AND n.nspname NOT LIKE 'pg\_%' {% if server_type == 'ppas' %} AND n.nspname NOT LIKE 'pg\_%' {% if server_type == 'ppas' %}
AND n.nspname NOT IN ('information_schema', 'pgagent', 'dbo', 'sys') {% else %} AND n.nspname NOT IN ('information_schema', 'pgagent', 'sys') {% else %}
AND n.nspname NOT IN ('information_schema') {% endif %} AND n.nspname NOT IN ('information_schema') {% endif %}
{%- endmacro %} {%- endmacro %}
{### Below macro is used in types fetching sql ###} {### Below macro is used in types fetching sql ###}
{% macro VALID_TYPE_CATALOGS(server_type) -%} {% macro VALID_TYPE_CATALOGS(server_type) -%}
{% if server_type == 'ppas' %} {% if server_type == 'ppas' %}
AND nsp.nspname NOT IN ('information_schema', 'pgagent', 'dbo', 'sys') {% else %} AND nsp.nspname NOT IN ('information_schema', 'pgagent', 'sys') {% else %}
AND nsp.nspname NOT IN ('information_schema') {% endif %} AND nsp.nspname NOT IN ('information_schema') {% endif %}
{%- endmacro %} {%- endmacro %}

View File

@ -1,5 +1,5 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_catalog.pg_namespace nsp FROM pg_catalog.pg_namespace nsp
WHERE nsp.oid={{scid}}::oid AND ( WHERE nsp.oid={{scid}}::oid AND (
(nspname = 'pg_catalog' AND EXISTS (nspname = 'pg_catalog' AND EXISTS

View File

@ -82,7 +82,7 @@ define('pgadmin.node.synonym', [
}), }),
synobjschema: ()=>getNodeListByName('schema', treeNodeInfo, itemNodeData, {}, (m)=>{ synobjschema: ()=>getNodeListByName('schema', treeNodeInfo, itemNodeData, {}, (m)=>{
// Exclude PPAS catalogs // Exclude PPAS catalogs
let exclude_catalogs = ['pg_catalog', 'sys', 'dbo', 'pgagent', 'information_schema', 'dbms_job_procedure']; let exclude_catalogs = ['pg_catalog', 'sys', 'pgagent', 'information_schema', 'dbms_job_procedure'];
return m && _.indexOf(exclude_catalogs, m.label) == -1; return m && _.indexOf(exclude_catalogs, m.label) == -1;
}), }),
getTargetObjectOptions: (targettype, synobjschema) => getTargetObjectOptions: (targettype, synobjschema) =>

View File

@ -1,5 +1,5 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_catalog.pg_namespace nsp FROM pg_catalog.pg_namespace nsp
WHERE nsp.oid={{scid}}::oid WHERE nsp.oid={{scid}}::oid
AND ( AND (

View File

@ -1,5 +1,5 @@
{% macro VALID_CATALOGS(server_type) -%} {% macro VALID_CATALOGS(server_type) -%}
AND n.nspname NOT LIKE 'pg\_%' {% if server_type == 'ppas' %} AND n.nspname NOT LIKE 'pg\_%' {% if server_type == 'ppas' %}
AND n.nspname NOT IN ('information_schema', 'pgagent', 'dbo', 'sys') {% else %} AND n.nspname NOT IN ('information_schema', 'pgagent', 'sys') {% else %}
AND n.nspname NOT IN ('information_schema') {% endif %} AND n.nspname NOT IN ('information_schema') {% endif %}
{%- endmacro %} {%- endmacro %}

View File

@ -8,20 +8,19 @@
({{ tbl }}.nspname = 'information_schema' AND EXISTS ({{ tbl }}.nspname = 'information_schema' AND EXISTS
(SELECT 1 FROM pg_catalog.pg_class (SELECT 1 FROM pg_catalog.pg_class
WHERE relname = 'tables' AND relnamespace = {{ tbl }}.oid LIMIT 1)) OR WHERE relname = 'tables' AND relnamespace = {{ tbl }}.oid LIMIT 1)) OR
({{ tbl }}.nspname = 'dbo' OR {{ tbl }}.nspname = 'sys') OR ({{ tbl }}.nspname = 'sys') OR
({{ tbl }}.nspname = 'dbms_job_procedure' AND EXISTS ({{ tbl }}.nspname = 'dbms_job_procedure' AND EXISTS
(SELECT 1 FROM pg_catalog.pg_proc (SELECT 1 FROM pg_catalog.pg_proc
WHERE pronamespace = {{ tbl }}.oid and proname = 'run_job' LIMIT 1)) WHERE pronamespace = {{ tbl }}.oid and proname = 'run_job' LIMIT 1))
{%- endmacro %} {%- endmacro %}
{% macro IS_CATALOG_SCHEMA(schema_col_name) -%} {% macro IS_CATALOG_SCHEMA(schema_col_name) -%}
{{ schema_col_name }} IN ('pg_catalog', 'pgagent', 'information_schema', 'dbo', 'sys', 'dbms_job_procedure') {{ schema_col_name }} IN ('pg_catalog', 'pgagent', 'information_schema', 'sys', 'dbms_job_procedure')
{%- endmacro %} {%- endmacro %}
{% macro LABELS(tbl, _) -%} {% macro LABELS(tbl, _) -%}
CASE {{ tbl }}.nspname CASE {{ tbl }}.nspname
WHEN 'pg_catalog' THEN '{{ _( 'PostgreSQL Catalog' ) }} (pg_catalog)' WHEN 'pg_catalog' THEN '{{ _( 'PostgreSQL Catalog' ) }} (pg_catalog)'
WHEN 'pgagent' THEN '{{ _( 'pgAgent Job Scheduler' ) }} (pgagent)' WHEN 'pgagent' THEN '{{ _( 'pgAgent Job Scheduler' ) }} (pgagent)'
WHEN 'information_schema' THEN '{{ _( 'ANSI' ) }} (information_schema)' WHEN 'information_schema' THEN '{{ _( 'ANSI' ) }} (information_schema)'
WHEN 'dbo' THEN 'Redmond (dbo)'
WHEN 'sys' THEN 'Redwood (sys)' WHEN 'sys' THEN 'Redwood (sys)'
ELSE {{ tbl }}.nspname ELSE {{ tbl }}.nspname
END AS name END AS name
@ -31,20 +30,19 @@
WHEN 'pg_catalog' THEN '{{ _( 'PostgreSQL Catalog' ) }} (pg_catalog)' WHEN 'pg_catalog' THEN '{{ _( 'PostgreSQL Catalog' ) }} (pg_catalog)'
WHEN 'pgagent' THEN '{{ _( 'pgAgent Job Scheduler' ) }} (pgagent)' WHEN 'pgagent' THEN '{{ _( 'pgAgent Job Scheduler' ) }} (pgagent)'
WHEN 'information_schema' THEN '{{ _( 'ANSI' ) }} (information_schema)' WHEN 'information_schema' THEN '{{ _( 'ANSI' ) }} (information_schema)'
WHEN 'dbo' THEN 'Redmond (dbo)'
WHEN 'sys' THEN 'Redwood (sys)' WHEN 'sys' THEN 'Redwood (sys)'
ELSE {{ schema_col_name }} ELSE {{ schema_col_name }}
END END
{%- endmacro %} {%- endmacro %}
{% macro DB_SUPPORT(tbl, schema_col_name) -%} {% macro DB_SUPPORT(tbl, schema_col_name) -%}
CASE CASE
WHEN {{ tbl }}.nspname = ANY('{information_schema,sys,dbo}') WHEN {{ tbl }}.nspname = ANY('{information_schema,sys}')
THEN false THEN false
ELSE true END ELSE true END
{%- endmacro %} {%- endmacro %}
{% macro DB_SUPPORT_SCHEMACOL(schema_col_name) -%} {% macro DB_SUPPORT_SCHEMACOL(schema_col_name) -%}
CASE CASE
WHEN {{ schema_col_name }} = ANY('{information_schema,sys,dbo}') WHEN {{ schema_col_name }} = ANY('{information_schema,sys}')
THEN false THEN false
ELSE true END ELSE true END
{%- endmacro %} {%- endmacro %}

View File

@ -175,14 +175,14 @@ const getCollNode = (node_type)=> {
* Sample path required by tree locator * Sample path required by tree locator
* Normal object - server_group/1.server/3.coll-database/3.database/13258.coll-schema/13258.schema/2200.coll-table/2200.table/41773 * Normal object - server_group/1.server/3.coll-database/3.database/13258.coll-schema/13258.schema/2200.coll-table/2200.table/41773
* pg_catalog schema - server_group/1.server/3.coll-database/3.database/13258.coll-catalog/13258.catalog/11.coll-table/11.table/2600 * pg_catalog schema - server_group/1.server/3.coll-database/3.database/13258.coll-catalog/13258.catalog/11.coll-table/11.table/2600
* Information Schema, dbo, sys: * Information Schema, sys:
* server_group/1.server/3.coll-database/3.database/13258.coll-catalog/13258.catalog/12967.coll-catalog_object/12967.catalog_object/13204 * server_group/1.server/3.coll-database/3.database/13258.coll-catalog/13258.catalog/12967.coll-catalog_object/12967.catalog_object/13204
* server_group/1.server/11.coll-database/11.database/13258.coll-catalog/13258.catalog/12967.coll-catalog_object/12967.catalog_object/12997.coll-catalog_object_column/12997.catalog_object_column/13 * server_group/1.server/11.coll-database/11.database/13258.coll-catalog/13258.catalog/12967.coll-catalog_object/12967.catalog_object/12997.coll-catalog_object_column/12997.catalog_object_column/13
* *
* Column catalog_level has values as * Column catalog_level has values as
* N - Not a catalog schema * N - Not a catalog schema
* D - Catalog schema with DB support - pg_catalog * D - Catalog schema with DB support - pg_catalog
* O - Catalog schema with object support only - info schema, dbo, sys * O - Catalog schema with object support only - info schema, sys
*/ */
const translateSearchObjectsPath = (nodeData, path, catalog_level)=> { const translateSearchObjectsPath = (nodeData, path, catalog_level)=> {
if (path === null) { if (path === null) {

View File

@ -124,7 +124,7 @@ class SearchObjectsHelper:
# Column catalog_level has values as # Column catalog_level has values as
# N - Not a catalog schema # N - Not a catalog schema
# D - Catalog schema with DB support - pg_catalog # D - Catalog schema with DB support - pg_catalog
# O - Catalog schema with object support only - info schema, dbo, sys # O - Catalog schema with object support only - info schema, sys
status, res = conn.execute_dict( status, res = conn.execute_dict(
self.get_sql('search.sql', self.get_sql('search.sql',
search_text=text.lower(), obj_type=obj_type, search_text=text.lower(), obj_type=obj_type,