Re: [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Nicolai Tufar <ntufar(at)gmail(dot)com>, Magnus Hagander <mha(at)sollentuna(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests
Date: 2005-03-10 21:19:33
Message-ID: 200503102119.j2ALJXs07493@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> First line of thought: we surely must not insert a snprintf into
> >> libpq.so unless it is 100% up to spec *and* has no performance issues
> >> ... neither of which can be claimed of the CVS-tip version.
>
> > Agreed, and we have to support all the 64-bit specifications a port
> > might support like %qd and %I64d as well as %lld. I have added that to
> > our current CVS version.
>
> I really dislike that idea and request that you revert it.
>
> > Is there any way we can have just gettext() call our snprintf under a
> > special name?
>
> The issue only comes up in libpq --- in the backend there is no reason
> that snprintf can't be our snprintf, and likewise in self-contained
> programs like psql. It might be worth the pain-in-the-neck quality to
> have libpq refer to the functions as pq_snprintf etc. Perhaps we could
> do this via macros
>
> #define snprintf pq_snprintf
>
> and not have to uglify the source code.

OK, here is a patch that changes snprintf() to pg_snprintf() for
platforms that need our snprintf. We do the same thing with
pgrename/pgunlink.

It manages to preserve printf-like argument checking in gcc.

I considered using a macro just in libpq but realized it was going to be
too ugly and too easy to break without us detecting it.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 8.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-03-10 21:25:56 Re: [pgsql-hackers-win32] Repleacement for src/port/snprintf.c
Previous Message Jaime Casanova 2005-03-10 20:14:23 Re: We are not following the spec for HAVING without GROUP BY

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Bruce Momjian 2005-03-10 21:25:56 Re: [pgsql-hackers-win32] Repleacement for src/port/snprintf.c
Previous Message Nicolai Tufar 2005-03-10 19:22:13 Re: [pgsql-hackers-win32] snprintf causes regression tests to fail

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-03-10 21:25:56 Re: [pgsql-hackers-win32] Repleacement for src/port/snprintf.c
Previous Message Kris Kiger 2005-03-10 19:57:30 Re: Functions and transactions