Re: Thread-safe getopt()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Thread-safe getopt()
Date: 2026-03-30 14:34:40
Message-ID: 2007091.1774881280@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
>>> Here's a patch for a thread-safe version of getopt(). I implemented it
>>> as two functions, pg_getopt_start() and pg_getopt_next(). Since
>>> there's no standard to follow, we have freedom on how to implement it,

Why in the world would we invent our own getopt API rather than
just replacing the relevant state variables with thread-local ones,
entirely internally to getopt.c?

It's not like this is a performance-critical code path. I think
the cognitive load for developers of having to learn YA API should
weigh against doing things this way.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-03-30 14:38:27 Re: [PATCH] Add support for INSERT ... SET syntax
Previous Message Heikki Linnakangas 2026-03-30 14:30:35 Re: Thread-safe getopt()