Patch for str_numth() in PG 7.4

Started by Andreas 'ads' Scherbaumover 17 years ago7 messageshackers
Jump to latest
#1Andreas 'ads' Scherbaum
adsmail@wars-nicht.de

Hello,

even if 7.4 is almost at the end of it's lifetime i found a bug/problem
on a fairly new laptop (not surprising: during upgrade tests). All
timestamp regression tests failed, only "th" was emitted.

I tracked the problem done to the function str_numth() in
src/backend/utils/adt/formatting.c. The fix (attached) is easy: i
stole the function code from the latest 8.0 version which looks fare
more sane in handling the string pointers.

Since this patch is easy enough (replacing one line with three
lines of code), does not seem to break existing code and removes at
least one bug i ask to include this patch into the next 7.4 release (i
assume there will be at least one release if 7.4 reaches eol).

Thanks & kind regards

--
Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors

Attachments:

linebreaks_for_l_plus_2008-12-21.patchtext/x-patch; name=linebreaks_for_l_plus_2008-12-21.patchDownload+9-9
#2Bruce Momjian
bruce@momjian.us
In reply to: Andreas 'ads' Scherbaum (#1)
Re: Patch for str_numth() in PG 7.4

Andreas 'ads' Scherbaum <adsmail@wars-nicht.de> writes:

I tracked the problem done to the function str_numth() in
src/backend/utils/adt/formatting.c. The fix (attached) is easy: i
stole the function code from the latest 8.0 version which looks fare
more sane in handling the string pointers.

I think you attached the wrong patch.

*** src/bin/psql/describe.c	2008-12-21 13:19:40.000000000 +0100
--- src/bin/psql/describe.c.orig	2008-12-21 02:16:31.000000000 +0100
***************
*** 464,476 ****
"       d.datctype as \"%s\",\n",
gettext_noop("Collation"),
gettext_noop("Ctype"));
! 	if (pset.sversion >= 80100)
! 	    appendPQExpBuffer(&buf,
! 					  "       pg_catalog.array_to_string(d.datacl, E'\\n') as \"%s\"",
! 					  gettext_noop("Access Privileges"));
! 	else
! 	    appendPQExpBuffer(&buf,
! 					  "       pg_catalog.array_to_string(d.datacl, '\\n') as \"%s\"",
gettext_noop("Access Privileges"));
if (verbose && pset.sversion >= 80200)
appendPQExpBuffer(&buf,
--- 464,471 ----
"       d.datctype as \"%s\",\n",
gettext_noop("Collation"),
gettext_noop("Ctype"));
! 	appendPQExpBuffer(&buf,
! 					  "       d.datacl as \"%s\"",
gettext_noop("Access Privileges"));
if (verbose && pset.sversion >= 80200)
appendPQExpBuffer(&buf,

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

#3Andreas 'ads' Scherbaum
adsmail@wars-nicht.de
In reply to: Andreas 'ads' Scherbaum (#1)
Re: Patch for str_numth() in PG 7.4

Hello all,

On Mon, 12 Jan 2009 22:55:32 +0100 Andreas 'ads' Scherbaum wrote:

I tracked the problem done to the function str_numth() in
src/backend/utils/adt/formatting.c. The fix (attached) is easy: i
stole the function code from the latest 8.0 version which looks fare
more sane in handling the string pointers.

Now with the correct patch attached, thanks to anyone who pointed this
out ;-)

Kind regards

--
Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors

Attachments:

formatting-str_numth-7.4.patchtext/x-patch; name=formatting-str_numth-7.4.patchDownload+4-4
#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Andreas 'ads' Scherbaum (#3)
Re: Patch for str_numth() in PG 7.4

Andreas 'ads' Scherbaum wrote:

Hello all,

On Mon, 12 Jan 2009 22:55:32 +0100 Andreas 'ads' Scherbaum wrote:

I tracked the problem done to the function str_numth() in
src/backend/utils/adt/formatting.c. The fix (attached) is easy: i
stole the function code from the latest 8.0 version which looks fare
more sane in handling the string pointers.

Now with the correct patch attached, thanks to anyone who pointed this
out ;-)

This was fixed on 1.84 of formatting.c for 8.0 (but not backpatched for
no apparent reason), which also changed some other stuff in that file.
The complete patch is attached.

revision 1.84
date: 2005-01-12 22:40:13 -0300; author: tgl; state: Exp; lines: +9 -7;
branches: 1.84.4;
Remove unportable assumption that it's okay to use the target buffer
of an sprintf() as a source string. Demonstrably does not work with
recent gcc and/or glibc on some platforms.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachments:

patchtext/plain; charset=us-asciiDownload+15-15
#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#4)
Re: Patch for str_numth() in PG 7.4

Alvaro Herrera <alvherre@commandprompt.com> writes:

This was fixed on 1.84 of formatting.c for 8.0 (but not backpatched for
no apparent reason), which also changed some other stuff in that file.
The complete patch is attached.

I dunno why I didn't back-patch that; feel free to do so. Better do the
whole thing, because anything that chokes on str_numth's abuse of
sprintf is not going to like those other cases either.

regards, tom lane

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#5)
Re: Patch for str_numth() in PG 7.4

Tom Lane wrote:

Alvaro Herrera <alvherre@commandprompt.com> writes:

This was fixed on 1.84 of formatting.c for 8.0 (but not backpatched for
no apparent reason), which also changed some other stuff in that file.
The complete patch is attached.

I dunno why I didn't back-patch that; feel free to do so. Better do the
whole thing, because anything that chokes on str_numth's abuse of
sprintf is not going to like those other cases either.

The other cases were already handled, so Andreas' initial patch was
enough -- applied.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#7Andreas 'ads' Scherbaum
adsmail@wars-nicht.de
In reply to: Alvaro Herrera (#6)
Re: Patch for str_numth() in PG 7.4

On Tue, 13 Jan 2009 12:30:09 -0300 Alvaro Herrera wrote:

The other cases were already handled, so Andreas' initial patch was
enough -- applied.

Thank you.

Bye

--
Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors