Re: [GENERAL] Querying libpq compile time options

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: spaminos-sql(at)yahoo(dot)com
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [GENERAL] Querying libpq compile time options
Date: 2006-05-18 19:18:12
Message-ID: 200605181918.k4IJICV25876@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

spaminos-sql(at)yahoo(dot)com wrote:
> From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
> > spaminos-sql(at)yahoo(dot)com wrote:
> > > Hi all
> > >
> > > I am writing an app that uses libpq, but because it is threaded I want to make sure that the dynamic
> > > library being used has been compiled with the right option.
> > > How do I do this?
> > >
> > > Is there a call such as "bool PQisThreadSafe()" that I can call?
>
> > Is this like detecting of libpq is SSL-enabled? I see PQgetssl(). Do
> > we need to add a libpq function to return true/false for threading?
> > Slony requires a threaded libpq, so it could do the test to prevent
> > wrong configurations. It would be nice to enabled threading by default,
> > but it is like SSL in that not all operating systems support it.
>
> Yes, this is exactly the issue I have: I want to enforce at runtime that the library being
> used is correct.
> btw, I noticed that for some reason the prebuild linux rpms for Fedora Core 3 are compiled
> without pthread support (and that's how I found out that I had to check the library on startup as I was getting strange lockups).
> I think the simplest is to add a new call just like the one you described for testing for ssl and tell people
> to call this function if they need the library to be thread safe.

Having heard no demand for libpq checking beyond threading, I have
implemented PQisthreadsafe(). I used PQisnonblocking() as an example.

One major argument for having a separate function, aside from lack of
demand for more, is that we are probably nearing the day when a theaded
libpq will be created by default on platforms that support it, and in
that case, there might not be a configure flag to check.

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
unknown_filename text/plain 3.8 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2006-05-18 19:22:58 Re: GUI Interface
Previous Message Tom Lane 2006-05-18 17:16:08 Re: autovacuum "connections" are hidden

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-05-18 19:22:42 Re: [OT] MySQL is bad, but THIS bad?
Previous Message Joshua D. Drake 2006-05-18 19:17:24 Re: [OT] MySQL is bad, but THIS bad?

Browse pgsql-patches by date

  From Date Subject
Next Message Jim C. Nasby 2006-05-18 22:10:13 Re: [PATCH] Compression and on-disk sorting
Previous Message Bruce Momjian 2006-05-18 18:52:21 Re: [PORTS] solaris build problem with Sun compilers