dbTalk Databases Forums  

Re: [BUGS] BUG #1044: snprintf() shipped with PostgreSQL is not

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #1044: snprintf() shipped with PostgreSQL is not in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Denis N. Stepanov
 
Posts: n/a

Default Re: [BUGS] BUG #1044: snprintf() shipped with PostgreSQL is not - 01-11-2004 , 01:06 PM






On Thu, 8 Jan 2004, Tom Lane wrote:

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

I discovered this problem while porting libpq (client interface) on
RTEMS OS (rtems.org). This is an embedded OS and as many other embedded OSes it
lacks non-ANSI C functions (at least RTEMS image from my vendor does not have
them). snprintf()/vsnprintf() functions are not ANSI-compliant so they should be
used with care. This OS has POSIX thread support though I did not use it (i.e. I
keep all PgSQL activity in one thread, so the code was compiled without
--enable-thread-safety). The difficulty I observed is: if even I keep PgSQL
calls serialized, calling bare snprintf() from some other thread would likely
cause concurrent PgSQL call to fail. Quite a strange result for such an
inoffensive action, don't you think so?

Anyway, I have fixed this for my code but if you think that the change is
inappropriate for the main stream then let it be. I guess you would hear some
more complaints as there will be more ports on embedded platforms.

TL>
TL> regards, tom lane
TL>

--
Thanks,
Denis.




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Reply With Quote
  #2  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: [BUGS] BUG #1044: snprintf() shipped with PostgreSQL is not - 01-11-2004 , 01:55 PM






Denis N. Stepanov wrote:
Quote:
snprintf()/vsnprintf() functions are not ANSI-compliant
Yes, they are.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #3  
Old   
Denis N. Stepanov
 
Posts: n/a

Default Re: [BUGS] BUG #1044: snprintf() shipped with PostgreSQL is not - 01-18-2004 , 03:10 PM



On Sun, 11 Jan 2004, Peter Eisentraut wrote:

PE> Denis N. Stepanov wrote:
PE> > snprintf()/vsnprintf() functions are not ANSI-compliant
PE>
PE> Yes, they are.

Sorry, I was talking about ANSI X3.159-1989, which certainly does not declare
snprintf(). In practice it is diffucult to count on, say, C99-compliant C
runtime, especially for embedded systems.

Thanks,
Denis.



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.