Lists: | pgsql-committerspgsql-hackers |
---|
From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-25 08:11:14 |
Message-ID: | E1UK2Us-00081d-Au@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
Per warning from -Wmissing-format-attribute.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/ea988ee8c8b191615e730f930bcde6144a598688
Modified Files
--------------
src/bin/pg_dump/dumputils.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
Cc: | pgsql-hackers(at)postgresql(dot)org, pgsql-committers(at)postgresql(dot)org |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-25 13:36:18 |
Message-ID: | 11348.1364218578@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> writes:
> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
> Per warning from -Wmissing-format-attribute.
Hm, this is exactly what I removed yesterday, because it makes the build
fail outright on old gcc:
gcc -O1 -Wall -Wmissing-prototypes -Wpointer-arith -Wformat-security -fno-strict-aliasing -g -I../../../src/interfaces/libpq -I../../../src/include -D_XOPEN_SOURCE_EXTENDED -D_USE_CTYPE_MACROS -c -o pg_dump.o pg_dump.c
In file included from pg_backup.h:29,
from pg_backup_archiver.h:32,
from pg_dump.c:60:
dumputils.h:48: argument format specified for non-function `on_exit_msg_func'
make: *** [pg_dump.o] Error 1
Perhaps we have to refactor to avoid the use of a function variable
here. It didn't seem particularly critical to do it like that rather
than with, say, a bool.
Or maybe we should turn off that warning. It seems to be leaping to
conclusions about what the usage of the function variable is.
regards, tom lane
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>, pgsql-hackers(at)postgresql(dot)org, pgsql-committers(at)postgresql(dot)org |
Subject: | Re: pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-25 15:06:25 |
Message-ID: | 515067F1.7050500@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 25.03.2013 15:36, Tom Lane wrote:
> Heikki Linnakangas<heikki(dot)linnakangas(at)iki(dot)fi> writes:
>> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
>> Per warning from -Wmissing-format-attribute.
>
> Hm, this is exactly what I removed yesterday, because it makes the build
> fail outright on old gcc:
>
> gcc -O1 -Wall -Wmissing-prototypes -Wpointer-arith -Wformat-security -fno-strict-aliasing -g -I../../../src/interfaces/libpq -I../../../src/include -D_XOPEN_SOURCE_EXTENDED -D_USE_CTYPE_MACROS -c -o pg_dump.o pg_dump.c
> In file included from pg_backup.h:29,
> from pg_backup_archiver.h:32,
> from pg_dump.c:60:
> dumputils.h:48: argument format specified for non-function `on_exit_msg_func'
> make: *** [pg_dump.o] Error 1
>
> Perhaps we have to refactor to avoid the use of a function variable
> here. It didn't seem particularly critical to do it like that rather
> than with, say, a bool.
Hmm. exit_horribly() is also used in pg_dumpall, so if you just put a
call to a function in parallel.c in there, the linker will complain when
linking pg_dumpall.
BTW, we never reset on_exit_msg_func, even after getting out of parallel
mode by calling ParallelBackupEnd(). The Assert in
parallel_exit_msg_func() will fail if it gets called after
ParallelBackupEnd().
The attached seems to work. With this patch, on_exit_msg_func() is gone.
There's a different implementation of exit_horribly for pg_dumpall and
pg_dump/restore. In pg_dumpall, it just calls vwrite_msg(). In
pg_dump/restore's version, the logic from parallel_exit_msg_func() is
moved directly to exit_horribly().
> Or maybe we should turn off that warning. It seems to be leaping to
> conclusions about what the usage of the function variable is.
Oh? Its conclusion seems correct to me: the function variable takes
printf-like arguments.
- Heikki
Attachment | Content-Type | Size |
---|---|---|
avoid-printf-like-function-var.patch | text/x-diff | 6.0 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org, pgsql-committers(at)postgresql(dot)org |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 00:02:11 |
Message-ID: | 23868.1364256131@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
> On 25.03.2013 15:36, Tom Lane wrote:
>> Heikki Linnakangas<heikki(dot)linnakangas(at)iki(dot)fi> writes:
>>> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
>>> Per warning from -Wmissing-format-attribute.
>> Hm, this is exactly what I removed yesterday, because it makes the build
>> fail outright on old gcc:
> The attached seems to work. With this patch, on_exit_msg_func() is gone.
> There's a different implementation of exit_horribly for pg_dumpall and
> pg_dump/restore. In pg_dumpall, it just calls vwrite_msg(). In
> pg_dump/restore's version, the logic from parallel_exit_msg_func() is
> moved directly to exit_horribly().
Seems probably reasonable, though if we're taking exit_horribly out of
dumputils.c, meseems it ought not be declared in dumputils.h anymore.
Can we put that declaration someplace else, rather than commenting it
with an apology?
regards, tom lane
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 07:51:50 |
Message-ID: | 51515396.3090302@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 26.03.2013 02:02, Tom Lane wrote:
> Heikki Linnakangas<hlinnakangas(at)vmware(dot)com> writes:
>> On 25.03.2013 15:36, Tom Lane wrote:
>>> Heikki Linnakangas<heikki(dot)linnakangas(at)iki(dot)fi> writes:
>>>> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
>>>> Per warning from -Wmissing-format-attribute.
>
>>> Hm, this is exactly what I removed yesterday, because it makes the build
>>> fail outright on old gcc:
>
>> The attached seems to work. With this patch, on_exit_msg_func() is gone.
>> There's a different implementation of exit_horribly for pg_dumpall and
>> pg_dump/restore. In pg_dumpall, it just calls vwrite_msg(). In
>> pg_dump/restore's version, the logic from parallel_exit_msg_func() is
>> moved directly to exit_horribly().
>
> Seems probably reasonable, though if we're taking exit_horribly out of
> dumputils.c, meseems it ought not be declared in dumputils.h anymore.
> Can we put that declaration someplace else, rather than commenting it
> with an apology?
Ugh, the patch I posted doesn't actually work, because dumputils.c is
also used in psql and some scripts, so you get a linker error in those.
psql and scripts don't use exit_horribly or many of the other functions
in dumputils.c, so I think we should split dumputils.c into two parts
anyway. fmtId and the other functions that are used by psql in one file,
and the functions that are only shared between pg_dumpall and pg_dump in
another. Then there's also functions that are used by pg_dump and
pg_restore, but not pg_dumpall or psql.
I'll try moving things around a bit...
- Heikki
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 17:26:26 |
Message-ID: | 5151DA42.1090400@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 26.03.2013 09:51, Heikki Linnakangas wrote:
> On 26.03.2013 02:02, Tom Lane wrote:
>> Heikki Linnakangas<hlinnakangas(at)vmware(dot)com> writes:
>>> On 25.03.2013 15:36, Tom Lane wrote:
>>>> Heikki Linnakangas<heikki(dot)linnakangas(at)iki(dot)fi> writes:
>>>>> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
>>>>> Per warning from -Wmissing-format-attribute.
>>
>>>> Hm, this is exactly what I removed yesterday, because it makes the
>>>> build
>>>> fail outright on old gcc:
>>
>>> The attached seems to work. With this patch, on_exit_msg_func() is gone.
>>> There's a different implementation of exit_horribly for pg_dumpall and
>>> pg_dump/restore. In pg_dumpall, it just calls vwrite_msg(). In
>>> pg_dump/restore's version, the logic from parallel_exit_msg_func() is
>>> moved directly to exit_horribly().
>>
>> Seems probably reasonable, though if we're taking exit_horribly out of
>> dumputils.c, meseems it ought not be declared in dumputils.h anymore.
>> Can we put that declaration someplace else, rather than commenting it
>> with an apology?
>
> Ugh, the patch I posted doesn't actually work, because dumputils.c is
> also used in psql and some scripts, so you get a linker error in those.
> psql and scripts don't use exit_horribly or many of the other functions
> in dumputils.c, so I think we should split dumputils.c into two parts
> anyway. fmtId and the other functions that are used by psql in one file,
> and the functions that are only shared between pg_dumpall and pg_dump in
> another. Then there's also functions that are used by pg_dump and
> pg_restore, but not pg_dumpall or psql.
>
> I'll try moving things around a bit...
This is what I came up with. I created a new file, misc.c (for lack of a
better name), for things that are shared by pg_dump and pg_restore, but
not pg_dumpall or other programs. I moved all the parallel stuff from
dumputils.c to parallel.c, and everything else that's not used outside
pg_dump and pg_restore to misc.c. I moved exit_horribly() to parallel.c,
because it needs to do things differently in parallel mode.
I still used a function pointer, not for the printf-style message
printing routine, but for making dumputils.c independent of parallel
mode. getThreadLocalPQBuffer() is now a function pointer; the default
implementation just uses a static variable, but when pg_dump/restore
enters parallel mode, it points the function pointer to a version that
uses thread-local storage (on windows).
- Heikki
Attachment | Content-Type | Size |
---|---|---|
refactor-dumputils.patch | text/x-diff | 27.1 KB |
From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 17:59:34 |
Message-ID: | 20130326175934.GA3881@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Heikki Linnakangas wrote:
> This is what I came up with. I created a new file, misc.c (for lack
> of a better name), for things that are shared by pg_dump and
> pg_restore, but not pg_dumpall or other programs. I moved all the
> parallel stuff from dumputils.c to parallel.c, and everything else
> that's not used outside pg_dump and pg_restore to misc.c. I moved
> exit_horribly() to parallel.c, because it needs to do things
> differently in parallel mode.
Not happy with misc.c as a filename. How about pg_dump_utils.c or
pg_dump_misc.c? I think the comment at the top should explicitely say
that the file is intended not to be linked in pg_dumpall.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 20:14:53 |
Message-ID: | 1364328893.48039.YahooMailNeo@web162901.mail.bf1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> Not happy with misc.c as a filename.
We already have two misc.c files:
src/backend/utils/adt/misc.c
src/interfaces/ecpg/ecpglib/misc.c
I much prefer not to repeat the same filename in different
directories if we can avoid it.
> How about pg_dump_utils.c or pg_dump_misc.c?
Those seem reasonable to me.
--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-26 20:20:19 |
Message-ID: | 20130326202019.GA32088@awork2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 2013-03-26 13:14:53 -0700, Kevin Grittner wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
>
> > Not happy with misc.c as a filename.
>
> We already have two misc.c files:
>
> src/backend/utils/adt/misc.c
> src/interfaces/ecpg/ecpglib/misc.c
>
> I much prefer not to repeat the same filename in different
> directories if we can avoid it.
>
> > How about pg_dump_utils.c or pg_dump_misc.c?
>
> Those seem reasonable to me.
I vote against including pg_ in the filename, for an implementation
private file that seems duplicative.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-27 08:01:17 |
Message-ID: | 5152A74D.8020308@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 26.03.2013 22:14, Kevin Grittner wrote:
> Alvaro Herrera<alvherre(at)2ndquadrant(dot)com> wrote:
>
>> Not happy with misc.c as a filename.
>
> We already have two misc.c files:
>
> src/backend/utils/adt/misc.c
> src/interfaces/ecpg/ecpglib/misc.c
>
> I much prefer not to repeat the same filename in different
> directories if we can avoid it.
>
>> How about pg_dump_utils.c or pg_dump_misc.c?
>
> Those seem reasonable to me.
pg_dump_utils.c could be confused with dumputils.c. And I'd rather not
have pg_dump in the filename, because the file is for functions that are
used in both pg_dump and pg_restore. To add to the confusion, there's
also common.c, which is only used by pg_dump (historical reasons).
There's a bunch of files called pg_backup_*.c that are also shared
between pg_dump and pg_restore, so perhaps pg_backup_utils.c?
- Heikki
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Kevin Grittner <kgrittn(at)ymail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-27 13:28:05 |
Message-ID: | 9564.1364390885@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
>> Alvaro Herrera<alvherre(at)2ndquadrant(dot)com> wrote:
>>> Not happy with misc.c as a filename.
> There's a bunch of files called pg_backup_*.c that are also shared
> between pg_dump and pg_restore, so perhaps pg_backup_utils.c?
Works for me. There's inherently not going to be a lot of content
in this filename, so we aren't going to get anything particularly
memorable (though I agree with the duplicativeness argument against
"misc.c").
regards, tom lane
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Kevin Grittner <kgrittn(at)ymail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt. |
Date: | 2013-03-27 16:20:26 |
Message-ID: | 51531C4A.9010807@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-committers pgsql-hackers |
On 27.03.2013 15:28, Tom Lane wrote:
> Heikki Linnakangas<hlinnakangas(at)vmware(dot)com> writes:
>>> Alvaro Herrera<alvherre(at)2ndquadrant(dot)com> wrote:
>>>> Not happy with misc.c as a filename.
>
>> There's a bunch of files called pg_backup_*.c that are also shared
>> between pg_dump and pg_restore, so perhaps pg_backup_utils.c?
>
> Works for me.
Ok, sold.
- Heikki