Обсуждение: Patch for str_numth() in PG 7.4

Поиск
Список
Период
Сортировка

Patch for str_numth() in PG 7.4

От
Andreas 'ads' Scherbaum
Дата:
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

Вложения

Re: Patch for str_numth() in PG 7.4

От
Gregory Stark
Дата:
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!


Re: Patch for str_numth() in PG 7.4

От
Andreas 'ads' Scherbaum
Дата:
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

Вложения

Re: Patch for str_numth() in PG 7.4

От
Alvaro Herrera
Дата:
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

Вложения

Re: Patch for str_numth() in PG 7.4

От
Tom Lane
Дата:
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


Re: Patch for str_numth() in PG 7.4

От
Alvaro Herrera
Дата:
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


Re: Patch for str_numth() in PG 7.4

От
Andreas 'ads' Scherbaum
Дата:
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