public inbox for [email protected]help / color / mirror / Atom feed
[pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters 4+ messages / 2 participants [nested] [flat]
* [pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters @ 2016-09-12 09:42 Surinder Kumar <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Surinder Kumar @ 2016-09-12 09:42 UTC (permalink / raw) To: pgadmin-hackers Hi, Please find attached patch with fix. *Changes:* 1) Take a list of "function argument types", create a string separated by comma(removing trailing comma). 2) Function arguments in ALTER and GRANT not necessarily to have *argument mode, name, *they are optional. Only type is required. Now GRANT statement is represented as *GRANT EXECUTE ON FUNCTION test_schema.test_func(integer, integer, integer) TO postgres *as in pgadmin3. Please review. -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers Attachments: [application/octet-stream] RM1683.patch (3.9K, 3-RM1683.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py index 785ba33..0fbed1b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py @@ -906,34 +906,34 @@ class FunctionView(PGChildNodeView, DataTypeReader): resp_data = self._fetch_properties(gid, sid, did, scid, fnid) # Fetch the function definition. args = u'' - args_without_name = u'' + args_without_name = [] cnt = 1 args_list = [] + if 'arguments' in resp_data and len(resp_data['arguments']) > 0: args_list = resp_data['arguments'] resp_data['args'] = resp_data['arguments'] for a in args_list: if (('argmode' in a and a['argmode'] != 'OUT' and - a['argmode'] is not None + a['argmode'] is not None ) or 'argmode' not in a): if 'argmode' in a: args += a['argmode'] + " " - args_without_name += a['argmode'] + " " if 'argname' in a and a['argname'] != '' \ and a['argname'] is not None: args += self.qtIdent( self.conn, a['argname']) + " " if 'argtype' in a: args += a['argtype'] - args_without_name += a['argtype'] + args_without_name.append(a['argtype']) if cnt < len(args_list): args += ', ' - args_without_name += ', ' cnt += 1 resp_data['func_args'] = args.strip(' ') - resp_data['func_args_without'] = args_without_name.strip(' ') + + resp_data['func_args_without'] = ', '.join(args_without_name) if self.node_type == 'procedure': object_type = 'procedure' @@ -1158,7 +1158,7 @@ class FunctionView(PGChildNodeView, DataTypeReader): data['acl'] = parse_priv_to_db(data['acl'], ["X"]) args = u'' - args_without_name = u'' + args_without_name = [] cnt = 1 args_list = [] if 'arguments' in data and len(data['arguments']) > 0: @@ -1171,28 +1171,27 @@ class FunctionView(PGChildNodeView, DataTypeReader): ) or 'argmode' not in a): if 'argmode' in a: args += a['argmode'] + " " - args_without_name += a['argmode'] + " " if 'argname' in a and a['argname'] != '' \ and a['argname'] is not None: args += self.qtIdent( self.conn, a['argname']) + " " if 'argtype' in a: args += a['argtype'] - args_without_name += a['argtype'] + args_without_name.append(a['argtype']) if cnt < len(args_list): args += ', ' - args_without_name += ', ' + args_without_name += ',' cnt += 1 data['func_args'] = args.strip(' ') - data['func_args_without'] = args_without_name.strip(' ') + + data['func_args_without'] = ', '.join(args_without_name) # Create mode SQL = render_template("/".join([self.sql_template_path, 'create.sql']), data=data, is_sql=is_sql) return True, SQL.strip('\n') - def _fetch_properties(self, gid, sid, did, scid, fnid=None): """ Return Function Properties which will be used in properties, ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters @ 2016-09-12 10:24 Surinder Kumar <[email protected]> parent: Surinder Kumar <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Surinder Kumar @ 2016-09-12 10:24 UTC (permalink / raw) To: pgadmin-hackers This patch doesn't fix the issue in Procedure node. I will send updated patch. On Mon, Sep 12, 2016 at 3:12 PM, Surinder Kumar < [email protected]> wrote: > Hi, > > Please find attached patch with fix. > *Changes:* > 1) Take a list of "function argument types", create a string separated by > comma(removing trailing comma). > 2) Function arguments in ALTER and GRANT not necessarily to have *argument > mode, name, *they are optional. Only type is required. > Now GRANT statement is represented as > > *GRANT EXECUTE ON FUNCTION test_schema.test_func(integer, integer, > integer) TO postgres *as in pgadmin3. > > > Please review. > ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters @ 2016-09-12 10:57 Surinder Kumar <[email protected]> parent: Surinder Kumar <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Surinder Kumar @ 2016-09-12 10:57 UTC (permalink / raw) To: pgadmin-hackers Hi I forgot to remove a line args_without_name += ', ' from the code in previous patch, thus it adds extra commas into the function arguments in case of procedures only. It is now fixed. Please find updated v2 patch and review. On Mon, Sep 12, 2016 at 3:54 PM, Surinder Kumar < [email protected]> wrote: > This patch doesn't fix the issue in Procedure node. I will send updated > patch. > > On Mon, Sep 12, 2016 at 3:12 PM, Surinder Kumar < > [email protected]> wrote: > >> Hi, >> >> Please find attached patch with fix. >> *Changes:* >> 1) Take a list of "function argument types", create a string separated by >> comma(removing trailing comma). >> 2) Function arguments in ALTER and GRANT not necessarily to have *argument >> mode, name, *they are optional. Only type is required. >> Now GRANT statement is represented as >> >> *GRANT EXECUTE ON FUNCTION test_schema.test_func(integer, integer, >> integer) TO postgres *as in pgadmin3. >> >> >> Please review. >> > > -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers Attachments: [application/octet-stream] RM1683_v2.patch (3.8K, 3-RM1683_v2.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py index 785ba33..f269dcb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py @@ -906,34 +906,34 @@ class FunctionView(PGChildNodeView, DataTypeReader): resp_data = self._fetch_properties(gid, sid, did, scid, fnid) # Fetch the function definition. args = u'' - args_without_name = u'' + args_without_name = [] cnt = 1 args_list = [] + if 'arguments' in resp_data and len(resp_data['arguments']) > 0: args_list = resp_data['arguments'] resp_data['args'] = resp_data['arguments'] for a in args_list: if (('argmode' in a and a['argmode'] != 'OUT' and - a['argmode'] is not None + a['argmode'] is not None ) or 'argmode' not in a): if 'argmode' in a: args += a['argmode'] + " " - args_without_name += a['argmode'] + " " if 'argname' in a and a['argname'] != '' \ and a['argname'] is not None: args += self.qtIdent( self.conn, a['argname']) + " " if 'argtype' in a: args += a['argtype'] - args_without_name += a['argtype'] + args_without_name.append(a['argtype']) if cnt < len(args_list): args += ', ' - args_without_name += ', ' cnt += 1 resp_data['func_args'] = args.strip(' ') - resp_data['func_args_without'] = args_without_name.strip(' ') + + resp_data['func_args_without'] = ', '.join(args_without_name) if self.node_type == 'procedure': object_type = 'procedure' @@ -1158,7 +1158,7 @@ class FunctionView(PGChildNodeView, DataTypeReader): data['acl'] = parse_priv_to_db(data['acl'], ["X"]) args = u'' - args_without_name = u'' + args_without_name = [] cnt = 1 args_list = [] if 'arguments' in data and len(data['arguments']) > 0: @@ -1171,28 +1171,26 @@ class FunctionView(PGChildNodeView, DataTypeReader): ) or 'argmode' not in a): if 'argmode' in a: args += a['argmode'] + " " - args_without_name += a['argmode'] + " " if 'argname' in a and a['argname'] != '' \ and a['argname'] is not None: args += self.qtIdent( self.conn, a['argname']) + " " if 'argtype' in a: args += a['argtype'] - args_without_name += a['argtype'] + args_without_name.append(a['argtype']) if cnt < len(args_list): args += ', ' - args_without_name += ', ' cnt += 1 data['func_args'] = args.strip(' ') - data['func_args_without'] = args_without_name.strip(' ') + + data['func_args_without'] = ', '.join(args_without_name) # Create mode SQL = render_template("/".join([self.sql_template_path, 'create.sql']), data=data, is_sql=is_sql) return True, SQL.strip('\n') - def _fetch_properties(self, gid, sid, did, scid, fnid=None): """ Return Function Properties which will be used in properties, ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Re: [pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters @ 2016-09-12 14:21 Dave Page <[email protected]> parent: Surinder Kumar <[email protected]> 0 siblings, 0 replies; 4+ messages in thread From: Dave Page @ 2016-09-12 14:21 UTC (permalink / raw) To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers Thanks, applied. On Mon, Sep 12, 2016 at 11:57 AM, Surinder Kumar <[email protected]> wrote: > Hi > > I forgot to remove a line args_without_name += ', ' from the code in > previous patch, thus it adds extra commas into the function arguments in > case of procedures only. > It is now fixed. > Please find updated v2 patch and review. > > > On Mon, Sep 12, 2016 at 3:54 PM, Surinder Kumar > <[email protected]> wrote: >> >> This patch doesn't fix the issue in Procedure node. I will send updated >> patch. >> >> On Mon, Sep 12, 2016 at 3:12 PM, Surinder Kumar >> <[email protected]> wrote: >>> >>> Hi, >>> >>> Please find attached patch with fix. >>> Changes: >>> 1) Take a list of "function argument types", create a string separated by >>> comma(removing trailing comma). >>> 2) Function arguments in ALTER and GRANT not necessarily to have argument >>> mode, name, they are optional. Only type is required. >>> Now GRANT statement is represented as >>> >>> GRANT EXECUTE ON FUNCTION test_schema.test_func(integer, integer, >>> integer) TO postgres as in pgadmin3. >>> >>> >>> Please review. >> >> > > > > -- > Sent via pgadmin-hackers mailing list ([email protected]) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgadmin-hackers > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2016-09-12 14:21 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-09-12 09:42 [pgAdmin4][Patch]: RM1683 - Reverse engineered SQL for function ALTERs/ACLs is incorrect with OUT parameters Surinder Kumar <[email protected]> 2016-09-12 10:24 ` Surinder Kumar <[email protected]> 2016-09-12 10:57 ` Surinder Kumar <[email protected]> 2016-09-12 14:21 ` Dave Page <[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