Re: BUG #1044: snprintf() shipped with PostgreSQL is not thread

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: D(dot)N(dot)Stepanov(at)inp(dot)nsk(dot)su, PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #1044: snprintf() shipped with PostgreSQL is not thread
Date: 2004-01-08 17:15:26
Message-ID: 200401081715.i08HFQQ28979@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org> writes:
> > Some OSes lack proper snprintf()/vsnprintf() fuctions so PostgreSQL includes
> > its own version (src/port/snprintf.c) during building. Unfortunately, this
> > version of snprintf() is not reentrant (it uses global vars to keep internal
> > state), so for example running libpq-based concurrent applications (threads)
> > causes libpq fuctions to fail sometimes.
>
> What platforms have workable thread support but not snprintf? I think
> this change is not likely to accomplish much except clutter the snprintf
> code ...

What we could do is to throw a compile #error if you hit our own
snprintf() and are compiling with threads enabled.

Patch attached and applied.

--
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 659 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-01-08 17:18:40 Re: BUG #1044: snprintf() shipped with PostgreSQL is not thread safe
Previous Message Tom Lane 2004-01-08 14:47:54 Re: BUG #1044: snprintf() shipped with PostgreSQL is not thread safe