From b134ae2cb4d0a57833eb93e5fecece669214b16d Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Wed, 7 Jun 2017 13:40:11 +0100 Subject: [PATCH] Fix the RE-SQL for for views to properly qualify trigger function names. Fixes #2381 --- .../servers/databases/schemas/views/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 836018b24..17a7df6f8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -896,15 +896,26 @@ class ViewNode(PGChildNodeView, VacuumSettings): trigger['oid'], columns) res_rows = trigger_definition(res_rows) - res_rows['schema'] = res_rows['nspname'] - # It should be relname and not table, but in create.sql # (which is referred from many places) we have used # data.table and not data.relname so compatibility add new key as # table in res_rows. res_rows['table'] = res_rows['relname'] - res_rows['tfunction'] = self.qtIdent(self.conn, res_rows['schema'], res_rows['tfunction']) + # Get trigger function with its schema name + SQL = render_template("/".join([self.trigger_temp_path, + 'sql/#{0}#/get_triggerfunctions.sql'.format(self.manager.version)]), + tgfoid=res_rows['tgfoid'], + show_system_objects=self.blueprint.show_system_objects) + + status, result = self.conn.execute_dict(SQL) + if not status: + return internal_server_error(errormsg=result) + + # Update the trigger function which we have fetched with schema name + if 'rows' in result and len(result['rows']) > 0 and \ + 'tfunctions' in result['rows'][0]: + res_rows['tfunction'] = result['rows'][0]['tfunctions'] # Format arguments if len(res_rows['custom_tgargs']) > 1: