diff --git a/docs/en_US/release_notes_3_1.rst b/docs/en_US/release_notes_3_1.rst index 67b7ee814..3f53d37c9 100644 --- a/docs/en_US/release_notes_3_1.rst +++ b/docs/en_US/release_notes_3_1.rst @@ -34,4 +34,5 @@ Bug fixes | `Bug #3333 `_ - Ensure the runtime core application is setup before trying to access any settings | `Bug #3342 `_ - Set SESSION_COOKIE_SAMESITE='Lax' per Flask recommendation to prevents sending cookies with CSRF-prone requests from external sites, such as submitting a form | `Bug #3353 `_ - Handle errors properly if they occur when renaming a database -| `Bug #3392 `_ - Fix IPv6 support in the container build. \ No newline at end of file +| `Bug #3392 `_ - Fix IPv6 support in the container build. +| `Bug #3409 `_ - Avoid an exception on GreenPlum when retrieving RE-SQL on a table. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql new file mode 100644 index 000000000..2d34accfb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql @@ -0,0 +1,23 @@ +SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, + nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, + COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'), + substring(pg_get_triggerdef(t.oid), 'WHEN (.*) \\$trigger')) AS whenclause, + -- We need to convert tgargs column bytea datatype to array datatype + (string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, +{% if datlastsysoid %} + (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, +{% endif %} + (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, + (CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger +FROM pg_trigger t + JOIN pg_class cl ON cl.oid=tgrelid + JOIN pg_namespace na ON na.oid=relnamespace + LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) + LEFT OUTER JOIN pg_proc p ON p.oid=t.tgfoid + LEFT OUTER JOIN pg_language l ON l.oid=p.prolang +WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID +{% if trid %} + AND t.oid = {{trid}}::OID +{% endif %} +ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql index 2d34accfb..9af811859 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql @@ -1,23 +1 @@ -SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, - nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, - COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'), - substring(pg_get_triggerdef(t.oid), 'WHEN (.*) \\$trigger')) AS whenclause, - -- We need to convert tgargs column bytea datatype to array datatype - (string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, -{% if datlastsysoid %} - (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, -{% endif %} - (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, - (CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger -FROM pg_trigger t - JOIN pg_class cl ON cl.oid=tgrelid - JOIN pg_namespace na ON na.oid=relnamespace - LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) - LEFT OUTER JOIN pg_proc p ON p.oid=t.tgfoid - LEFT OUTER JOIN pg_language l ON l.oid=p.prolang -WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -ORDER BY tgname; +SELECT 1 WHERE 1 = 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py index 9ef065419..2faabd077 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py @@ -1003,6 +1003,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): if not status: return internal_server_error(errormsg=res) + if len(res['rows']) == 0: + continue data = dict(res['rows'][0]) # Adding parent into data dict, will be using it while creating sql data['schema'] = schema