mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that the 'template1' database should not be visible after pg_upgrade. Fixes #5875
This commit is contained in:
committed by
Akshay Joshi
parent
21333490ef
commit
cb0a914099
@@ -19,6 +19,7 @@ Housekeeping
|
|||||||
Bug fixes
|
Bug fixes
|
||||||
*********
|
*********
|
||||||
|
|
||||||
|
| `Issue #5875 <https://redmine.postgresql.org/issues/5875>`_ - Ensure that the 'template1' database should not be visible after pg_upgrade.
|
||||||
| `Issue #5965 <https://redmine.postgresql.org/issues/5965>`_ - Ensure that the macro query result should be download properly.
|
| `Issue #5965 <https://redmine.postgresql.org/issues/5965>`_ - Ensure that the macro query result should be download properly.
|
||||||
| `Issue #6047 <https://redmine.postgresql.org/issues/6047>`_ - Fixed an issue where the dirty indicator stays active even if all changes were undone.
|
| `Issue #6047 <https://redmine.postgresql.org/issues/6047>`_ - Fixed an issue where the dirty indicator stays active even if all changes were undone.
|
||||||
| `Issue #6058 <https://redmine.postgresql.org/issues/6058>`_ - Ensure that the rename panel should be disabled when the SQL file opened in the query tool.
|
| `Issue #6058 <https://redmine.postgresql.org/issues/6058>`_ - Ensure that the rename panel should be disabled when the SQL file opened in the query tool.
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class DatabaseView(PGChildNodeView):
|
|||||||
return gone(errormsg=_("Could not find the server."))
|
return gone(errormsg=_("Could not find the server."))
|
||||||
|
|
||||||
self.datlastsysoid = 0
|
self.datlastsysoid = 0
|
||||||
|
self.datistemplate = False
|
||||||
if action and action in ["drop"]:
|
if action and action in ["drop"]:
|
||||||
self.conn = self.manager.connection()
|
self.conn = self.manager.connection()
|
||||||
elif 'did' in kwargs:
|
elif 'did' in kwargs:
|
||||||
@@ -195,6 +196,11 @@ class DatabaseView(PGChildNodeView):
|
|||||||
if self._db['datallowconn'] is False:
|
if self._db['datallowconn'] is False:
|
||||||
self.conn = self.manager.connection()
|
self.conn = self.manager.connection()
|
||||||
self.db_allow_connection = False
|
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:
|
else:
|
||||||
self.conn = self.manager.connection()
|
self.conn = self.manager.connection()
|
||||||
|
|
||||||
@@ -225,7 +231,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||||
conn=self.conn,
|
conn=self.conn,
|
||||||
last_system_oid=last_system_oid,
|
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)
|
status, res = self.conn.execute_dict(SQL, params)
|
||||||
|
|
||||||
@@ -277,7 +284,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".join([self.template_path, self._NODES_SQL]),
|
||||||
last_system_oid=last_system_oid,
|
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)
|
status, rset = self.conn.execute_dict(SQL, params)
|
||||||
|
|
||||||
@@ -335,6 +343,7 @@ class DatabaseView(PGChildNodeView):
|
|||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".join([self.template_path, self._NODES_SQL]),
|
||||||
last_system_oid=0,
|
last_system_oid=0,
|
||||||
|
show_system_objects=self.blueprint.show_system_objects,
|
||||||
)
|
)
|
||||||
status, rset = self.conn.execute_dict(SQL)
|
status, rset = self.conn.execute_dict(SQL)
|
||||||
|
|
||||||
@@ -353,7 +362,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
def node(self, gid, sid, did):
|
def node(self, gid, sid, did):
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".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)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
|
|
||||||
@@ -391,7 +401,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
|
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".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)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
|
|
||||||
@@ -425,7 +436,7 @@ class DatabaseView(PGChildNodeView):
|
|||||||
|
|
||||||
result = res['rows'][0]
|
result = res['rows'][0]
|
||||||
result['is_sys_obj'] = (
|
result['is_sys_obj'] = (
|
||||||
result['oid'] <= self.datlastsysoid)
|
result['oid'] <= self.datlastsysoid or self.datistemplate)
|
||||||
# Fetching variable for database
|
# Fetching variable for database
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, 'get_variables.sql']),
|
"/".join([self.template_path, 'get_variables.sql']),
|
||||||
@@ -617,7 +628,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
# We need oid of newly created database
|
# We need oid of newly created database
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".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(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
if SQL and SQL != "":
|
if SQL and SQL != "":
|
||||||
@@ -693,7 +705,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
status, rset = self.conn.execute_dict(
|
status, rset = self.conn.execute_dict(
|
||||||
render_template(
|
render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".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:
|
if not status:
|
||||||
@@ -797,7 +810,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
status, rset = self.conn.execute_dict(
|
status, rset = self.conn.execute_dict(
|
||||||
render_template(
|
render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".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:
|
if not status:
|
||||||
@@ -962,7 +976,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
status, rset = conn.execute_dict(
|
status, rset = conn.execute_dict(
|
||||||
render_template(
|
render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".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:
|
if not status:
|
||||||
@@ -1132,7 +1147,8 @@ class DatabaseView(PGChildNodeView):
|
|||||||
conn = self.manager.connection()
|
conn = self.manager.connection()
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".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)
|
status, res = conn.execute_dict(SQL)
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,11 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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 f(*args, **kwargs)
|
||||||
|
|
||||||
return wrap
|
return wrap
|
||||||
@@ -360,7 +365,9 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
gettext("Could not find the event trigger information."))
|
gettext("Could not find the event trigger information."))
|
||||||
|
|
||||||
result = res['rows'][0]
|
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)
|
result = self._formatter(result)
|
||||||
|
|
||||||
return True, result
|
return True, result
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ class ExtensionView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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 f(*args, **kwargs)
|
||||||
|
|
||||||
return wrap
|
return wrap
|
||||||
@@ -247,7 +252,7 @@ class ExtensionView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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]
|
return True, res['rows'][0]
|
||||||
|
|
||||||
|
|||||||
@@ -222,6 +222,11 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'foreign_data_wrappers/sql/#{0}#'.format(
|
self.template_path = 'foreign_data_wrappers/sql/#{0}#'.format(
|
||||||
self.manager.version
|
self.manager.version
|
||||||
@@ -372,7 +377,7 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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:
|
if res['rows'][0]['fdwoptions'] is not None:
|
||||||
res['rows'][0]['fdwoptions'] = tokenize_options(
|
res['rows'][0]['fdwoptions'] = tokenize_options(
|
||||||
|
|||||||
@@ -212,6 +212,11 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = "foreign_servers/sql/#{0}#".format(
|
self.template_path = "foreign_servers/sql/#{0}#".format(
|
||||||
self.manager.version
|
self.manager.version
|
||||||
@@ -360,7 +365,7 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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:
|
if res['rows'][0]['fsrvoptions'] is not None:
|
||||||
res['rows'][0]['fsrvoptions'] = tokenize_options(
|
res['rows'][0]['fsrvoptions'] = tokenize_options(
|
||||||
|
|||||||
@@ -229,6 +229,11 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'user_mappings/sql/#{0}#'.format(
|
self.template_path = 'user_mappings/sql/#{0}#'.format(
|
||||||
self.manager.version
|
self.manager.version
|
||||||
@@ -378,7 +383,7 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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:
|
if res['rows'][0]['umoptions'] is not None:
|
||||||
res['rows'][0]['umoptions'] = tokenize_options(
|
res['rows'][0]['umoptions'] = tokenize_options(
|
||||||
|
|||||||
@@ -234,6 +234,10 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = (
|
self.template_path = (
|
||||||
@@ -371,7 +375,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self._NOT_FOUND_LANG_INFORMATION)
|
return False, gone(self._NOT_FOUND_LANG_INFORMATION)
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
res['rows'][0]['is_sys_obj'] = (
|
||||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
|
||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, self._ACL_SQL]),
|
"/".join([self.template_path, self._ACL_SQL]),
|
||||||
|
|||||||
@@ -144,6 +144,12 @@ def check_precondition(f):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
if self.manager.server_type == 'gpdb':
|
if self.manager.server_type == 'gpdb':
|
||||||
_temp = self.gpdb_template_path(self.manager.version)
|
_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
|
# Making copy of output for future use
|
||||||
copy_data = dict(res['rows'][0])
|
copy_data = dict(res['rows'][0])
|
||||||
copy_data['is_sys_obj'] = (
|
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)
|
copy_data = self._formatter(copy_data, scid)
|
||||||
|
|
||||||
return ajax_response(
|
return ajax_response(
|
||||||
|
|||||||
@@ -150,6 +150,12 @@ class CatalogObjectView(PGChildNodeView):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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(
|
self.template_path = 'catalog_object/sql/{0}/#{1}#'.format(
|
||||||
'ppas' if self.manager.server_type == 'ppas' else 'pg',
|
'ppas' if self.manager.server_type == 'ppas' else 'pg',
|
||||||
self.manager.version
|
self.manager.version
|
||||||
@@ -296,7 +302,7 @@ class CatalogObjectView(PGChildNodeView):
|
|||||||
gettext("""Could not find the specified catalog object."""))
|
gettext("""Could not find the specified catalog object."""))
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
res['rows'][0]['is_sys_obj'] = (
|
||||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
res['rows'][0]['oid'] <= self.datlastsysoid or self.datistemplate)
|
||||||
|
|
||||||
return ajax_response(
|
return ajax_response(
|
||||||
response=res['rows'][0],
|
response=res['rows'][0],
|
||||||
|
|||||||
@@ -177,6 +177,12 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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.template_path = 'catalog_object_column/sql/#{0}#'.format(
|
||||||
self.manager.version)
|
self.manager.version)
|
||||||
|
|
||||||
@@ -278,7 +284,8 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
|||||||
return gone(gettext("""Could not find the specified column."""))
|
return gone(gettext("""Could not find the specified column."""))
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
res['rows'][0]['is_sys_obj'] = (
|
||||||
res['rows'][0]['attrelid'] <= self.datlastsysoid)
|
res['rows'][0]['attrelid'] <= self.datlastsysoid or
|
||||||
|
self.datistemplate)
|
||||||
|
|
||||||
return ajax_response(
|
return ajax_response(
|
||||||
response=res['rows'][0],
|
response=res['rows'][0],
|
||||||
|
|||||||
@@ -198,6 +198,11 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = compile_template_path(
|
self.template_path = compile_template_path(
|
||||||
'collations/sql/',
|
'collations/sql/',
|
||||||
@@ -356,7 +361,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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]
|
return True, res['rows'][0]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
#
|
#
|
||||||
# pgAdmin 4 - PostgreSQL Tools
|
# pgAdmin 4 - PostgreSQL Tools
|
||||||
@@ -264,6 +265,11 @@ class DomainConstraintView(PGChildNodeView):
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'domain_constraints/sql/#{0}#'.format(
|
self.template_path = 'domain_constraints/sql/#{0}#'.format(
|
||||||
self.manager.version)
|
self.manager.version)
|
||||||
@@ -403,7 +409,7 @@ class DomainConstraintView(PGChildNodeView):
|
|||||||
|
|
||||||
data = res['rows'][0]
|
data = res['rows'][0]
|
||||||
data['is_sys_obj'] = (
|
data['is_sys_obj'] = (
|
||||||
data['oid'] <= self.datlastsysoid)
|
data['oid'] <= self.datlastsysoid or self.datistemplate)
|
||||||
return ajax_response(
|
return ajax_response(
|
||||||
response=data,
|
response=data,
|
||||||
status=200
|
status=200
|
||||||
|
|||||||
@@ -344,6 +344,11 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set template path for sql scripts depending
|
||||||
# on the server version.
|
# on the server version.
|
||||||
self.template_path = compile_template_path(
|
self.template_path = compile_template_path(
|
||||||
@@ -1140,7 +1145,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||||||
|
|
||||||
data = res['rows'][0]
|
data = res['rows'][0]
|
||||||
data['is_sys_obj'] = (
|
data['is_sys_obj'] = (
|
||||||
data['oid'] <= self.datlastsysoid)
|
data['oid'] <= self.datlastsysoid or self.datistemplate)
|
||||||
|
|
||||||
if self.manager.version >= 90200:
|
if self.manager.version >= 90200:
|
||||||
# Fetch privileges
|
# Fetch privileges
|
||||||
|
|||||||
@@ -231,6 +231,12 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'fts_configurations/sql/#{0}#'.format(
|
self.template_path = 'fts_configurations/sql/#{0}#'.format(
|
||||||
self.manager.version)
|
self.manager.version)
|
||||||
@@ -384,7 +390,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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
|
# In edit mode fetch token/dictionary list also
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
|
|||||||
@@ -220,6 +220,10 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'fts_dictionaries/sql/#{0}#'.format(
|
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]['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
|
# Handle templates and its schema name properly
|
||||||
if res['rows'][0]['template_schema'] is not None and \
|
if res['rows'][0]['template_schema'] is not None and \
|
||||||
|
|||||||
@@ -234,6 +234,10 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# Set the template path for the SQL scripts
|
||||||
self.template_path = 'fts_parsers/sql/#{0}#'.format(
|
self.template_path = 'fts_parsers/sql/#{0}#'.format(
|
||||||
self.manager.version)
|
self.manager.version)
|
||||||
@@ -350,7 +354,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
_("Could not find the FTS Parser node in the database node."))
|
_("Could not find the FTS Parser node in the database node."))
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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]
|
return True, res['rows'][0]
|
||||||
|
|
||||||
@check_precondition
|
@check_precondition
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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.template_path = 'fts_templates/sql/#{0}#'.format(
|
||||||
self.manager.version)
|
self.manager.version)
|
||||||
|
|
||||||
@@ -324,7 +328,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if len(res['rows']) == 0:
|
if len(res['rows']) == 0:
|
||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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]
|
return True, res['rows'][0]
|
||||||
|
|
||||||
@check_precondition
|
@check_precondition
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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.template_path = 'sequences/sql/#{0}#'.format(
|
||||||
self.manager.version
|
self.manager.version
|
||||||
@@ -306,7 +310,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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']:
|
for row in res['rows']:
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
self.manager.db_info[kwargs['did']]['datlastsysoid'] \
|
||||||
if self.manager.db_info is not None and \
|
if self.manager.db_info is not None and \
|
||||||
kwargs['did'] in self.manager.db_info else 0
|
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
|
# we will set template path for sql scripts
|
||||||
self.template_path = 'synonyms/sql/#{0}#'.format(
|
self.template_path = 'synonyms/sql/#{0}#'.format(
|
||||||
@@ -420,7 +424,8 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return False, gone(self.not_found_error_msg())
|
return False, gone(self.not_found_error_msg())
|
||||||
|
|
||||||
res['rows'][0]['is_sys_obj'] = (
|
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]
|
return True, res['rows'][0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return internal_server_error(errormsg=str(e))
|
return internal_server_error(errormsg=str(e))
|
||||||
|
|||||||
@@ -40,4 +40,6 @@ AND
|
|||||||
db.datname in ({{db_restrictions}})
|
db.datname in ({{db_restrictions}})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
AND db.datistemplate in (false, {{show_system_objects}})
|
||||||
|
|
||||||
ORDER BY datname;
|
ORDER BY datname;
|
||||||
|
|||||||
@@ -47,4 +47,6 @@ AND
|
|||||||
db.datname in ({{db_restrictions}})
|
db.datname in ({{db_restrictions}})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
AND db.datistemplate in (false, {{show_system_objects}})
|
||||||
|
|
||||||
ORDER BY datname;
|
ORDER BY datname;
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ AND
|
|||||||
db.datname in ({{db_restrictions}})
|
db.datname in ({{db_restrictions}})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
AND db.datistemplate in (false, {{show_system_objects}})
|
||||||
|
|
||||||
ORDER BY datname;
|
ORDER BY datname;
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ AND
|
|||||||
db.datname in ({{db_restrictions}})
|
db.datname in ({{db_restrictions}})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
AND db.datistemplate in (false, {{show_system_objects}})
|
||||||
|
|
||||||
ORDER BY datname;
|
ORDER BY datname;
|
||||||
|
|||||||
@@ -519,7 +519,8 @@ class Connection(BaseConnection):
|
|||||||
SELECT
|
SELECT
|
||||||
db.oid as did, db.datname, db.datallowconn,
|
db.oid as did, db.datname, db.datallowconn,
|
||||||
pg_encoding_to_char(db.encoding) AS serverencoding,
|
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
|
FROM
|
||||||
pg_database db
|
pg_database db
|
||||||
WHERE db.datname = current_database()""")
|
WHERE db.datname = current_database()""")
|
||||||
|
|||||||
Reference in New Issue
Block a user