Re: [HACKERS] libpq+MB/putenv(), getenv() clean up

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] libpq+MB/putenv(), getenv() clean up
Date: 2000-01-13 03:05:31
Message-ID: 11546.947732731@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp> writes:
> I have a plan to clean up the usage of putenv(), getenv() in libpq+MB
> configuration. This needs some interface changes with libpq in the
> frontend side. I'm not sure this is visible to end users or not, and I
> would like to hear from hackes.

I think it is a very good idea to remove getenv() from PQmblen().
getenv() is rather slow, at least on the machines I use, and having
to do it for each character processed is a huge performance hit.

PQmblen is exported by libpq (psql is an example of an application
that uses it). So very possibly, changing it would break a few client
applications. A possible answer is to leave PQmblen alone, and invent
a new routine with a different name that looks at PGconn. We could
deprecate PQmblen and delete it after a few releases. I'm not sure
if this is worth the trouble or not --- maybe it's OK to make a non-
compatible change to PQmblen.

> (1) While establishing a connection, if the environment variable
> PGCLIENTENCODING is not set, libpq asks the backend what the encoding
> for the database is.

> Above implementation has a design flaw since it is not multithread-safe.

You would still do one getenv() during connection setup, right, to see
if PGCLIENTENCODING is set? If you don't, that would be a significant
change in behavior that might make a lot of people unhappy.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2000-01-13 03:14:54 RE: [HACKERS] TODO list updated
Previous Message Bruce Momjian 2000-01-13 03:02:40 Re: [HACKERS] TODO list updated