Lists: | pgsql-hackers |
---|
From: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com> |
---|---|
To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com> |
Subject: | [patch] some PQExpBuffer are not destroyed in pg_dump |
Date: | 2020-04-07 02:42:40 |
Message-ID: | 05bcbc5857f948efa0b451b85a48ae10@G08CNEXMBPEKD06.g08.fujitsu.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi al
In getDefaultACLs function, some PQExpBuffer are not destroy
File: src/bin/pg_dump/pg_dump.c
DefaultACLInfo *
getDefaultACLs(Archive *fout, int *numDefaultACLs)
{
......
if (fout->remoteVersion >= 90600)
{
PQExpBuffer acl_subquery = createPQExpBuffer(); // *** acl_subquery not destroyed ***
PQExpBuffer racl_subquery = createPQExpBuffer(); // *** racl_subquery not destroyed ***
PQExpBuffer initacl_subquery = createPQExpBuffer(); // *** initacl_subquery not destroyed ***
PQExpBuffer initracl_subquery = createPQExpBuffer(); // *** initracl_subquery not destroyed ***
buildACLQueries(acl_subquery, racl_subquery, initacl_subquery,
initracl_subquery, "defaclacl", "defaclrole",
"CASE WHEN defaclobjtype = 'S' THEN 's' ELSE defaclobjtype END::\"char\"",
dopt->binary_upgrade);
appendPQExpBuffer(query, "SELECT d.oid, d.tableoid, "
"(%s d.defaclrole) AS defaclrole, "
"d.defaclnamespace, "
"d.defaclobjtype, "
"%s AS defaclacl, "
"%s AS rdefaclacl, "
"%s AS initdefaclacl, "
"%s AS initrdefaclacl "
"FROM pg_default_acl d "
"LEFT JOIN pg_init_privs pip ON "
"(d.oid = pip.objoid "
"AND pip.classoid = 'pg_default_acl'::regclass "
"AND pip.objsubid = 0) ",
username_subquery,
acl_subquery->data,
racl_subquery->data,
initacl_subquery->data,
initracl_subquery->data);
}
......
Here is a patch.
Best Regards!
Attachment | Content-Type | Size |
---|---|---|
pg_dump.patch | application/octet-stream | 506 bytes |
From: | Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com> |
---|---|
To: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [patch] some PQExpBuffer are not destroyed in pg_dump |
Date: | 2020-04-13 07:51:06 |
Message-ID: | CA+fd4k49nPyHh3RmzrwFFRjo0woabqL14gg30KkUS75w_+y5wg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, 7 Apr 2020 at 11:42, Zhang, Jie <zhangjie2(at)cn(dot)fujitsu(dot)com> wrote:
>
> Hi al
>
> In getDefaultACLs function, some PQExpBuffer are not destroy
>
Yes, it looks like an oversight. It's related to the commit
e2090d9d20d809 which is back-patched to 9.6.
The patch looks good to me.
Regards,
--
Masahiko Sawada http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com> |
Cc: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [patch] some PQExpBuffer are not destroyed in pg_dump |
Date: | 2020-04-14 01:11:56 |
Message-ID: | 20200414011156.GD1492@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Apr 13, 2020 at 04:51:06PM +0900, Masahiko Sawada wrote:
> On Tue, 7 Apr 2020 at 11:42, Zhang, Jie <zhangjie2(at)cn(dot)fujitsu(dot)com> wrote:
>> In getDefaultACLs function, some PQExpBuffer are not destroy
>
> Yes, it looks like an oversight. It's related to the commit
> e2090d9d20d809 which is back-patched to 9.6.
>
> The patch looks good to me.
Indeed. Any code path of pg_dump calling buildACLQueries() clears up
things, and I think that it is a better practice to clean up properly
PQExpBuffer stuff even if there is always the argument that pg_dump
is a tool running in a "short"-term context. So I will backpatch that
unless there are any objections from others.
The part I am actually rather amazed of here is that I don't recall
seeing Coverity complaining about leaks after this commit. Perhaps it
just got lost.
--
Michael
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com> |
Cc: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [patch] some PQExpBuffer are not destroyed in pg_dump |
Date: | 2020-04-15 07:05:10 |
Message-ID: | 20200415070510.GL1492@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Apr 14, 2020 at 10:11:56AM +0900, Michael Paquier wrote:
> Indeed. Any code path of pg_dump calling buildACLQueries() clears up
> things, and I think that it is a better practice to clean up properly
> PQExpBuffer stuff even if there is always the argument that pg_dump
> is a tool running in a "short"-term context. So I will backpatch that
> unless there are any objections from others.
And done as of 8f4ee44.
--
Michael