Results 1 to 5 of 5

Thread: Libpq Problem

  1. #1
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    6

    Unanswered: Libpq Problem

    Hi,

    PQExecPrepared seems to return a result of some other query. We have a multithreaded application, but only one thread uses a connection at one time and connections are reused. I have also noticed that sometimes our application crashes inside PQExecPrepared.

    Any pointers will be helpful.

    Samarth

  2. #2
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    libpq is only thread safe if it was configured that way.

    int PQisthreadsafe();

    Returns 1 if the libpq is thread-safe and 0 if it is not.

    PostgreSQL Programming Guide - Behavior in Threaded Programs

  3. #3
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    6
    Thanks for the reply!

    We had suspected this issue and we had compiled libpq in thread safe mode. When we use the Thread Test example (for testing if it is thread safe) that libpq provides, it says successful. But when we check with PQisthreadsafe() it returns 0.

    When we configure we get the following logs:

    checking for the pthreads library -lpthreads... no
    checking whether pthreads work without any flags... no
    checking whether pthreads work with -Kthread... no
    checking whether pthreads work with -kthread... no
    checking for the pthreads library -llthread... no
    checking whether pthreads work with -pthread... yes
    checking whether pthreads work with -pthreads... no
    checking whether pthreads work with -mthreads... no
    checking for the pthreads library -lpthread... yes
    checking whether pthreads work with --thread-safe... no
    checking whether pthreads work with -mt... no
    checking for the pthreads library -lpthreadGC2... no
    checking pthread.h usability... yes
    checking pthread.h presence... yes
    checking for pthread.h... yes

    Are we doing anything wrong?

    Thanks in advance for the help.

    Samarth

  4. #4
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    I'm going to have to refer you to one of the Postgres mailing lists. Some one there will be able to help you. Many of the core developers hang out there and answer questions.

    PostgreSQL: Mailing Lists

  5. #5
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    6
    Thanks for the pointer!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •