pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: to_char(): have format 'OF' only show the leading negative sign
8+ messages / 3 participants
[nested] [flat]
* pgsql: to_char(): have format 'OF' only show the leading negative sign
@ 2015-04-29 01:03 Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Momjian @ 2015-04-29 01:03 UTC (permalink / raw)
To: pgsql-committers
to_char(): have format 'OF' only show the leading negative sign
Previously both hours and minutes displayed as negative.
Report by David Pozsar
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/9b43d73b3f9bef276a46660920a01f0421c4323a
Modified Files
--------------
src/backend/utils/adt/formatting.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
@ 2015-04-29 14:11 ` Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
2015-04-29 21:04 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 8+ messages in thread
From: Stephen Frost @ 2015-04-29 14:11 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-committers
Bruce,
* Bruce Momjian (bruce@momjian.us) wrote:
> to_char(): have format 'OF' only show the leading negative sign
>
> Previously both hours and minutes displayed as negative.
>
> Report by David Pozsar
This is causing the following error for me:
/home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
/home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
^
Since abs() is declared to return just an int. I don't see it anywhere
in our tree and I'm not sure how portable it actually is, but labs() is
supposedly in C89, so perhaps that should be used here instead?
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
@ 2015-04-29 18:17 ` Robert Haas <robertmhaas@gmail.com>
2015-04-29 18:22 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
1 sibling, 1 reply; 8+ messages in thread
From: Robert Haas @ 2015-04-29 18:17 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Bruce Momjian <bruce@momjian.us>; pgsql-committers
On Wed, Apr 29, 2015 at 10:11 AM, Stephen Frost <sfrost@snowman.net> wrote:
> * Bruce Momjian (bruce@momjian.us) wrote:
>> to_char(): have format 'OF' only show the leading negative sign
>>
>> Previously both hours and minutes displayed as negative.
>>
>> Report by David Pozsar
>
> This is causing the following error for me:
>
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
> sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
> ^
>
> Since abs() is declared to return just an int. I don't see it anywhere
> in our tree and I'm not sure how portable it actually is, but labs() is
> supposedly in C89, so perhaps that should be used here instead?
I just removed the "l" for now, since %02d is used to print the result
of abs() elsewhere. If that isn't right, someone can re-fix my fix.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
@ 2015-04-29 18:22 ` Stephen Frost <sfrost@snowman.net>
2015-04-29 21:05 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Frost @ 2015-04-29 18:22 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Bruce Momjian <bruce@momjian.us>; pgsql-committers
* Robert Haas (robertmhaas@gmail.com) wrote:
> On Wed, Apr 29, 2015 at 10:11 AM, Stephen Frost <sfrost@snowman.net> wrote:
> > * Bruce Momjian (bruce@momjian.us) wrote:
> >> to_char(): have format 'OF' only show the leading negative sign
> >>
> >> Previously both hours and minutes displayed as negative.
> >>
> >> Report by David Pozsar
> >
> > This is causing the following error for me:
> >
> > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
> > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
> > sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
> > ^
> >
> > Since abs() is declared to return just an int. I don't see it anywhere
> > in our tree and I'm not sure how portable it actually is, but labs() is
> > supposedly in C89, so perhaps that should be used here instead?
>
> I just removed the "l" for now, since %02d is used to print the result
> of abs() elsewhere. If that isn't right, someone can re-fix my fix.
Works for me. I'm no longer seeing the warning.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
2015-04-29 18:22 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
@ 2015-04-29 21:05 ` Bruce Momjian <bruce@momjian.us>
2015-04-30 13:07 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Momjian @ 2015-04-29 21:05 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Robert Haas <robertmhaas@gmail.com>; pgsql-committers
On Wed, Apr 29, 2015 at 02:22:22PM -0400, Stephen Frost wrote:
> * Robert Haas (robertmhaas@gmail.com) wrote:
> > On Wed, Apr 29, 2015 at 10:11 AM, Stephen Frost <sfrost@snowman.net> wrote:
> > > * Bruce Momjian (bruce@momjian.us) wrote:
> > >> to_char(): have format 'OF' only show the leading negative sign
> > >>
> > >> Previously both hours and minutes displayed as negative.
> > >>
> > >> Report by David Pozsar
> > >
> > > This is causing the following error for me:
> > >
> > > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
> > > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
> > > sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
> > > ^
> > >
> > > Since abs() is declared to return just an int. I don't see it anywhere
> > > in our tree and I'm not sure how portable it actually is, but labs() is
> > > supposedly in C89, so perhaps that should be used here instead?
> >
> > I just removed the "l" for now, since %02d is used to print the result
> > of abs() elsewhere. If that isn't right, someone can re-fix my fix.
>
> Works for me. I'm no longer seeing the warning.
Oh, I see now that my commit generated a conflict and didn't apply.
Should we try labs() or just ignore it?
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
2015-04-29 18:22 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 21:05 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
@ 2015-04-30 13:07 ` Robert Haas <robertmhaas@gmail.com>
2015-04-30 13:21 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 8+ messages in thread
From: Robert Haas @ 2015-04-30 13:07 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-committers
On Wed, Apr 29, 2015 at 5:05 PM, Bruce Momjian <bruce@momjian.us> wrote:
> On Wed, Apr 29, 2015 at 02:22:22PM -0400, Stephen Frost wrote:
>> * Robert Haas (robertmhaas@gmail.com) wrote:
>> > On Wed, Apr 29, 2015 at 10:11 AM, Stephen Frost <sfrost@snowman.net> wrote:
>> > > * Bruce Momjian (bruce@momjian.us) wrote:
>> > >> to_char(): have format 'OF' only show the leading negative sign
>> > >>
>> > >> Previously both hours and minutes displayed as negative.
>> > >>
>> > >> Report by David Pozsar
>> > >
>> > > This is causing the following error for me:
>> > >
>> > > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
>> > > /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
>> > > sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
>> > > ^
>> > >
>> > > Since abs() is declared to return just an int. I don't see it anywhere
>> > > in our tree and I'm not sure how portable it actually is, but labs() is
>> > > supposedly in C89, so perhaps that should be used here instead?
>> >
>> > I just removed the "l" for now, since %02d is used to print the result
>> > of abs() elsewhere. If that isn't right, someone can re-fix my fix.
>>
>> Works for me. I'm no longer seeing the warning.
>
> Oh, I see now that my commit generated a conflict and didn't apply.
> Should we try labs() or just ignore it?
If the result is guaranteed to fit in an integer, then there's no
reason to adopt labs. If you think there are platforms where it would
overflow int but fit into long, then there might be a reason to change
it. All things being equal, it'd be nicer if we didn't need to use
labs(), because every function we depend on is another thing that can
break on some obscure platform.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
2015-04-29 18:22 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
2015-04-29 21:05 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-30 13:07 ` Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Robert Haas <robertmhaas@gmail.com>
@ 2015-04-30 13:21 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2015-04-30 13:21 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-committers
On Thu, Apr 30, 2015 at 09:07:45AM -0400, Robert Haas wrote:
> >> > > Since abs() is declared to return just an int. I don't see it anywhere
> >> > > in our tree and I'm not sure how portable it actually is, but labs() is
> >> > > supposedly in C89, so perhaps that should be used here instead?
> >> >
> >> > I just removed the "l" for now, since %02d is used to print the result
> >> > of abs() elsewhere. If that isn't right, someone can re-fix my fix.
> >>
> >> Works for me. I'm no longer seeing the warning.
> >
> > Oh, I see now that my commit generated a conflict and didn't apply.
> > Should we try labs() or just ignore it?
>
> If the result is guaranteed to fit in an integer, then there's no
> reason to adopt labs. If you think there are platforms where it would
> overflow int but fit into long, then there might be a reason to change
> it. All things being equal, it'd be nicer if we didn't need to use
> labs(), because every function we depend on is another thing that can
> break on some obscure platform.
I think abs() is fine; there is no risk of overflow from mod; thanks.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Re: pgsql: to_char(): have format 'OF' only show the leading negative sign Stephen Frost <sfrost@snowman.net>
@ 2015-04-29 21:04 ` Bruce Momjian <bruce@momjian.us>
1 sibling, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2015-04-29 21:04 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: pgsql-committers
On Wed, Apr 29, 2015 at 10:11:02AM -0400, Stephen Frost wrote:
> Bruce,
>
> * Bruce Momjian (bruce@momjian.us) wrote:
> > to_char(): have format 'OF' only show the leading negative sign
> >
> > Previously both hours and minutes displayed as negative.
> >
> > Report by David Pozsar
>
> This is causing the following error for me:
>
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
> sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
> ^
>
> Since abs() is declared to return just an int. I don't see it anywhere
> in our tree and I'm not sure how portable it actually is, but labs() is
> supposedly in C89, so perhaps that should be used here instead?
OK, I have switched to labs() and will keep an eye on the buildfarm;
patch attached. (There is already an uncomfortable amount of red
there.)
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Attachments:
to_char.diff (text/x-diff, 712B) download
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
new file mode 100644
index 576db95..dbff94d
*** a/src/backend/utils/adt/formatting.c
--- b/src/backend/utils/adt/formatting.c
*************** DCH_to_char(FormatNode *node, bool is_in
*** 2507,2513 ****
s += strlen(s);
if (tm->tm_gmtoff % SECS_PER_HOUR != 0)
{
! sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
s += strlen(s);
}
break;
--- 2507,2513 ----
s += strlen(s);
if (tm->tm_gmtoff % SECS_PER_HOUR != 0)
{
! sprintf(s, ":%02ld", labs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
s += strlen(s);
}
break;
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2015-04-30 13:21 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 01:03 pgsql: to_char(): have format 'OF' only show the leading negative sign Bruce Momjian <bruce@momjian.us>
2015-04-29 14:11 ` Stephen Frost <sfrost@snowman.net>
2015-04-29 18:17 ` Robert Haas <robertmhaas@gmail.com>
2015-04-29 18:22 ` Stephen Frost <sfrost@snowman.net>
2015-04-29 21:05 ` Bruce Momjian <bruce@momjian.us>
2015-04-30 13:07 ` Robert Haas <robertmhaas@gmail.com>
2015-04-30 13:21 ` Bruce Momjian <bruce@momjian.us>
2015-04-29 21:04 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox