Re: Patch to implement pg_current_logfile() function

From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: Christoph Berg <myon(at)debian(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch to implement pg_current_logfile() function
Date: 2016-11-23 16:21:52
Message-ID: cec5437e-6cc0-bebd-59dc-1f33fe4b2a97@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 23/11/2016 à 16:26, Tom Lane a écrit :
> "Karl O. Pinc" <kop(at)meme(dot)com> writes:
>> Maybe on the 2nd call to strtok() you could pass ""
>> as the 2nd argument? That'd be a little wonky but
>> the man page does not say you can't have an empty
>> set of delimiters. On the other hand strtok() is
>> not a perfect choice, you don't want to "collapse"
>> adjacent delimiters in the parsed string or ignore
>> leading spaces. I'd prefer a strstr() solution.
> I'd stay away from strtok() no matter what. The process-wide static
> state it implies is dangerous: if you use it, you're betting that
> you aren't interrupting some caller's use, nor will any callee decide
> to use it. In a system as large as Postgres, that's a bad bet, or
> would be if we didn't discourage use of strtok() pretty hard.
>
> As far as I can find, there are exactly two users of strtok() in
> the backend, and they're already playing with fire because one
> calls the other (look in utils/misc/tzparser.c). I don't want the
> hazard to get any larger.
>
> regards, tom lane

Understood, I will remove and replace this call from the patch and more
generally from my programming.

--
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-11-23 16:33:38 Re: Typo in comment in file analyze.c [master branch]
Previous Message Kostiantyn Nemchenko 2016-11-23 15:55:38 Typo in comment in file analyze.c [master branch]