public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin] RM5875 template1 is shown after you use pg_upgrade
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin] RM5875 template1 is shown after you use pg_upgrade
@ 2020-12-15 09:16 Rahul Shirsat <[email protected]>
2020-12-16 06:42 ` Re: [pgAdmin] RM5875 template1 is shown after you use pg_upgrade Akshay Joshi <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Rahul Shirsat @ 2020-12-15 09:16 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Please find the attached patch below which resolves the issue of showing
template1 after pg_upgrade.
Testing of the patch has been done on :
1. Windows Server 2016 (PostgreSQL 12.5, compiled by Visual C++ build
1914, 64-bit & PostgreSQL 13.1, compiled by Visual C++ build 1914, 64-bit)
2. MacOSX
--
*Rahul Shirsat*
Senior Software Engineer | EnterpriseDB Corporation.
Attachments:
[application/octet-stream] RM5875.patch (34.0K, 3-RM5875.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index e7a69149a..ea4754ab3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -182,6 +182,7 @@ class DatabaseView(PGChildNodeView):
return gone(errormsg=_("Could not find the server."))
self.datlastsysoid = 0
+ self.datistemplate = False
if action and action in ["drop"]:
self.conn = self.manager.connection()
elif 'did' in kwargs:
@@ -195,6 +196,11 @@ class DatabaseView(PGChildNodeView):
if self._db['datallowconn'] is False:
self.conn = self.manager.connection()
self.db_allow_connection = False
+
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']][
+ 'datistemplate'] if 'datistemplate' in \
+ self.manager.db_info[kwargs['did']] else False
else:
self.conn = self.manager.connection()
@@ -225,7 +231,8 @@ class DatabaseView(PGChildNodeView):
"/".join([self.template_path, self._PROPERTIES_SQL]),
conn=self.conn,
last_system_oid=last_system_oid,
- db_restrictions=db_disp_res
+ db_restrictions=db_disp_res,
+ show_system_objects=self.blueprint.show_system_objects,
)
status, res = self.conn.execute_dict(SQL, params)
@@ -277,7 +284,8 @@ class DatabaseView(PGChildNodeView):
SQL = render_template(
"/".join([self.template_path, self._NODES_SQL]),
last_system_oid=last_system_oid,
- db_restrictions=db_disp_res
+ db_restrictions=db_disp_res,
+ show_system_objects=self.blueprint.show_system_objects,
)
status, rset = self.conn.execute_dict(SQL, params)
@@ -335,6 +343,7 @@ class DatabaseView(PGChildNodeView):
SQL = render_template(
"/".join([self.template_path, self._NODES_SQL]),
last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
status, rset = self.conn.execute_dict(SQL)
@@ -353,7 +362,8 @@ class DatabaseView(PGChildNodeView):
def node(self, gid, sid, did):
SQL = render_template(
"/".join([self.template_path, self._NODES_SQL]),
- did=did, conn=self.conn, last_system_oid=0
+ did=did, conn=self.conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
status, rset = self.conn.execute_2darray(SQL)
@@ -391,7 +401,8 @@ class DatabaseView(PGChildNodeView):
SQL = render_template(
"/".join([self.template_path, self._PROPERTIES_SQL]),
- did=did, conn=self.conn, last_system_oid=0
+ did=did, conn=self.conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
status, res = self.conn.execute_dict(SQL)
@@ -425,7 +436,7 @@ class DatabaseView(PGChildNodeView):
result = res['rows'][0]
result['is_sys_obj'] = (
- result['oid'] <= self.datlastsysoid)
+ result['oid'] <= self.datlastsysoid or self.datistemplate)
# Fetching variable for database
SQL = render_template(
"/".join([self.template_path, 'get_variables.sql']),
@@ -617,7 +628,8 @@ class DatabaseView(PGChildNodeView):
# We need oid of newly created database
SQL = render_template(
"/".join([self.template_path, self._PROPERTIES_SQL]),
- name=data['name'], conn=self.conn, last_system_oid=0
+ name=data['name'], conn=self.conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
SQL = SQL.strip('\n').strip(' ')
if SQL and SQL != "":
@@ -693,7 +705,8 @@ class DatabaseView(PGChildNodeView):
status, rset = self.conn.execute_dict(
render_template(
"/".join([self.template_path, self._NODES_SQL]),
- did=did, conn=self.conn, last_system_oid=0
+ did=did, conn=self.conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
)
if not status:
@@ -797,7 +810,8 @@ class DatabaseView(PGChildNodeView):
status, rset = self.conn.execute_dict(
render_template(
"/".join([self.template_path, self._NODES_SQL]),
- did=did, conn=self.conn, last_system_oid=0
+ did=did, conn=self.conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
)
if not status:
@@ -962,7 +976,8 @@ class DatabaseView(PGChildNodeView):
status, rset = conn.execute_dict(
render_template(
"/".join([self.template_path, self._NODES_SQL]),
- did=did, conn=conn, last_system_oid=0
+ did=did, conn=conn, last_system_oid=0,
+ show_system_objects=self.blueprint.show_system_objects,
)
)
if not status:
@@ -1132,7 +1147,8 @@ class DatabaseView(PGChildNodeView):
conn = self.manager.connection()
SQL = render_template(
"/".join([self.template_path, self._PROPERTIES_SQL]),
- did=did, conn=conn, last_system_oid=0
+ did=did, conn=conn, last_system_oid=0,
+ show_system_objects=False,
)
status, res = conn.execute_dict(SQL)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
index 077128cc0..2fcde2a7d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -201,6 +201,11 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate']\
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
return f(*args, **kwargs)
return wrap
@@ -360,7 +365,9 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
gettext("Could not find the event trigger information."))
result = res['rows'][0]
- result['is_sys_obj'] = (result['oid'] <= self.datlastsysoid)
+ result['is_sys_obj'] = (
+ result['oid'] <= self.datlastsysoid or
+ self.datistemplate)
result = self._formatter(result)
return True, result
diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
index e39172d0b..12e078f47 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
@@ -143,6 +143,11 @@ class ExtensionView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
return f(*args, **kwargs)
return wrap
@@ -247,7 +252,7 @@ class ExtensionView(PGChildNodeView, SchemaDiffObjectCompare):
)
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
return True, res['rows'][0]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index 94e5e0c4e..631ea9d6d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -222,6 +222,11 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = 'foreign_data_wrappers/sql/#{0}#'.format(
self.manager.version
@@ -372,7 +377,7 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
)
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
if res['rows'][0]['fdwoptions'] is not None:
res['rows'][0]['fdwoptions'] = tokenize_options(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
index 7f2baafb0..660a21a2d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
@@ -212,6 +212,11 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = "foreign_servers/sql/#{0}#".format(
self.manager.version
@@ -360,7 +365,7 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
if res['rows'][0]['fsrvoptions'] is not None:
res['rows'][0]['fsrvoptions'] = tokenize_options(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py
index 6ca8ce79e..adafc1283 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py
@@ -229,6 +229,11 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = 'user_mappings/sql/#{0}#'.format(
self.manager.version
@@ -378,7 +383,7 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
if res['rows'][0]['umoptions'] is not None:
res['rows'][0]['umoptions'] = tokenize_options(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
index 7bea0b4cc..e065e8e8b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
@@ -234,6 +234,10 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
# Set the template path for the SQL scripts
self.template_path = (
@@ -371,7 +375,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self._NOT_FOUND_LANG_INFORMATION)
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
sql = render_template(
"/".join([self.template_path, self._ACL_SQL]),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
index 69d917d18..d7e3da9b6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
@@ -144,6 +144,12 @@ def check_precondition(f):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
if self.manager.server_type == 'gpdb':
_temp = self.gpdb_template_path(self.manager.version)
@@ -571,7 +577,7 @@ It may have been removed by another user.
# Making copy of output for future use
copy_data = dict(res['rows'][0])
copy_data['is_sys_obj'] = (
- copy_data['oid'] <= self.datlastsysoid)
+ copy_data['oid'] <= self.datlastsysoid or self.datistemplate)
copy_data = self._formatter(copy_data, scid)
return ajax_response(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
index 20742bf63..d7ca485b9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
@@ -150,6 +150,12 @@ class CatalogObjectView(PGChildNodeView):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
self.template_path = 'catalog_object/sql/{0}/#{1}#'.format(
'ppas' if self.manager.server_type == 'ppas' else 'pg',
self.manager.version
@@ -296,7 +302,7 @@ class CatalogObjectView(PGChildNodeView):
gettext("""Could not find the specified catalog object."""))
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
return ajax_response(
response=res['rows'][0],
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
index cad20243c..20d518750 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
@@ -177,6 +177,12 @@ class CatalogObjectColumnsView(PGChildNodeView):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
self.template_path = 'catalog_object_column/sql/#{0}#'.format(
self.manager.version)
@@ -278,7 +284,8 @@ class CatalogObjectColumnsView(PGChildNodeView):
return gone(gettext("""Could not find the specified column."""))
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['attrelid'] <= self.datlastsysoid)
+ res['rows'][0]['attrelid'] <= self.datlastsysoid or
+ self.datistemplate)
return ajax_response(
response=res['rows'][0],
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
index 13535ee51..1606ca4c1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
@@ -198,6 +198,11 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = compile_template_path(
'collations/sql/',
@@ -356,7 +361,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
return True, res['rows'][0]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
index 071885372..15ccbfa54 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
@@ -1,3 +1,4 @@
+
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
@@ -264,6 +265,11 @@ class DomainConstraintView(PGChildNodeView):
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = 'domain_constraints/sql/#{0}#'.format(
self.manager.version)
@@ -403,7 +409,7 @@ class DomainConstraintView(PGChildNodeView):
data = res['rows'][0]
data['is_sys_obj'] = (
- data['oid'] <= self.datlastsysoid)
+ data['oid'] <= self.datlastsysoid or self.datistemplate)
return ajax_response(
response=data,
status=200
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
index 1afe38fa3..7d001b596 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
@@ -344,6 +344,11 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set template path for sql scripts depending
# on the server version.
self.template_path = compile_template_path(
@@ -1140,7 +1145,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
data = res['rows'][0]
data['is_sys_obj'] = (
- data['oid'] <= self.datlastsysoid)
+ data['oid'] <= self.datlastsysoid or self.datistemplate)
if self.manager.version >= 90200:
# Fetch privileges
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
index bd59cac5a..f07179241 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
@@ -231,6 +231,12 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
+
# Set the template path for the SQL scripts
self.template_path = 'fts_configurations/sql/#{0}#'.format(
self.manager.version)
@@ -384,7 +390,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
)
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
# In edit mode fetch token/dictionary list also
sql = render_template(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
index b99987b7a..542e6b6e8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
@@ -220,6 +220,10 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
# Set the template path for the SQL scripts
self.template_path = 'fts_dictionaries/sql/#{0}#'.format(
@@ -393,7 +397,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
))
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
# Handle templates and its schema name properly
if res['rows'][0]['template_schema'] is not None and \
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py
index b6bc88166..a22c3c766 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py
@@ -234,6 +234,10 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
# Set the template path for the SQL scripts
self.template_path = 'fts_parsers/sql/#{0}#'.format(
self.manager.version)
@@ -350,7 +354,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
_("Could not find the FTS Parser node in the database node."))
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
return True, res['rows'][0]
@check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
index 0b831e753..f83d6b8ca 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
@@ -214,6 +214,10 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
self.template_path = 'fts_templates/sql/#{0}#'.format(
self.manager.version)
@@ -324,7 +328,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
if len(res['rows']) == 0:
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
return True, res['rows'][0]
@check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
index e2d562125..55d9cfbd2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -142,6 +142,10 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
self.template_path = 'sequences/sql/#{0}#'.format(
self.manager.version
@@ -306,7 +310,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
for row in res['rows']:
sql = render_template(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
index d0c97e17c..4539adf77 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
@@ -210,6 +210,10 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
if self.manager.db_info is not None and \
kwargs['did'] in self.manager.db_info else 0
+ self.datistemplate = \
+ self.manager.db_info[kwargs['did']]['datistemplate'] \
+ if self.manager.db_info is not None and \
+ kwargs['did'] in self.manager.db_info else False
# we will set template path for sql scripts
self.template_path = 'synonyms/sql/#{0}#'.format(
@@ -420,7 +424,8 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return False, gone(self.not_found_error_msg())
res['rows'][0]['is_sys_obj'] = (
- res['rows'][0]['oid'] <= self.datlastsysoid)
+ res['rows'][0]['oid'] <= self.datlastsysoid or
+ self.datistemplate)
return True, res['rows'][0]
except Exception as e:
return internal_server_error(errormsg=str(e))
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
index 597462edd..3927df34c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
@@ -40,4 +40,6 @@ AND
db.datname in ({{db_restrictions}})
{% endif %}
+AND db.datistemplate in (false, {{show_system_objects}})
+
ORDER BY datname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
index 22f0fc7ec..bf4e59b2e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
@@ -47,4 +47,6 @@ AND
db.datname in ({{db_restrictions}})
{% endif %}
+AND db.datistemplate in (false, {{show_system_objects}})
+
ORDER BY datname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/nodes.sql
index 82c58d0e2..7dd63ff7a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/nodes.sql
@@ -14,4 +14,6 @@ AND
db.datname in ({{db_restrictions}})
{% endif %}
+AND db.datistemplate in (false, {{show_system_objects}})
+
ORDER BY datname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql
index c936f64d6..558495514 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql
@@ -31,4 +31,6 @@ AND
db.datname in ({{db_restrictions}})
{% endif %}
+AND db.datistemplate in (false, {{show_system_objects}})
+
ORDER BY datname;
diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py
index 4f40e652b..f19bb20e3 100644
--- a/web/pgadmin/utils/driver/psycopg2/connection.py
+++ b/web/pgadmin/utils/driver/psycopg2/connection.py
@@ -519,7 +519,8 @@ class Connection(BaseConnection):
SELECT
db.oid as did, db.datname, db.datallowconn,
pg_encoding_to_char(db.encoding) AS serverencoding,
- has_database_privilege(db.oid, 'CREATE') as cancreate, datlastsysoid
+ has_database_privilege(db.oid, 'CREATE') as cancreate, datlastsysoid,
+ datistemplate
FROM
pg_database db
WHERE db.datname = current_database()""")
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin] RM5875 template1 is shown after you use pg_upgrade
2020-12-15 09:16 [pgAdmin] RM5875 template1 is shown after you use pg_upgrade Rahul Shirsat <[email protected]>
@ 2020-12-16 06:42 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Akshay Joshi @ 2020-12-16 06:42 UTC (permalink / raw)
To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers
Thanks, patch applied.
On Tue, Dec 15, 2020 at 2:46 PM Rahul Shirsat <
[email protected]> wrote:
> Hi Hackers,
>
> Please find the attached patch below which resolves the issue of showing
> template1 after pg_upgrade.
>
> Testing of the patch has been done on :
>
> 1. Windows Server 2016 (PostgreSQL 12.5, compiled by Visual C++ build
> 1914, 64-bit & PostgreSQL 13.1, compiled by Visual C++ build 1914, 64-bit)
> 2. MacOSX
>
>
> --
> *Rahul Shirsat*
> Senior Software Engineer | EnterpriseDB Corporation.
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-12-16 06:42 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 09:16 [pgAdmin] RM5875 template1 is shown after you use pg_upgrade Rahul Shirsat <[email protected]>
2020-12-16 06:42 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox