Questions tagged [libpq]

libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.

libpq is also the underlying engine for several other PostgreSQL application interfaces, including those written for C++, Perl, Python, Tcl and ECPG. So some aspects of libpq's behavior will be important to you if you use one of those packages.

Client programs that use libpq must include the header file libpq-fe.h and must link with the libpq library.

345 questions
1
vote
1 answer

PostgreSQL: How can I create a temporary user and database for my unit tests?

I'm developing a C++ web application and I'm using PostgreSQL with libpqxx, on Ubuntu 16.04. The issue I'm having is that I need a portable (over Linux systems) way to run my unit tests. What I have now is a class that controls database calls. I'd…
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
1
vote
1 answer

libpq Postgres PQexecParams 2 hours timeout

I am using libpq v9.6.8 for my Application (running 24/7), which inserts data into the postgres database. I also run PQexecParams to get the table columns. But randomly (sometimes just once a week, but then twice a weekend) this blocking…
Tobi
  • 924
  • 1
  • 10
  • 39
1
vote
1 answer

organize the PostgreSQL database connection parameters using libpq?

I'm trying to figure out the correct way to pass database connection parameters to this libpq connection control function. PQconnectdbParams PGconn *PQconnectdbParams(const char * const *keywords, const char * const *values, int…
patrik kings
  • 442
  • 6
  • 15
1
vote
1 answer

postgresql consume more memory in db server for long running connection

We have a c++ server application which is connecting to postgresql database using libpq library. Application creating 100s of connection to database and most of the connection's life time is application scope. Initially application was running…
Srini2k6
  • 380
  • 1
  • 5
  • 19
1
vote
1 answer

libpq: lo_open() returns 0

I am trying to create large objects using libpq and encountered the problem. In the following code: Oid oid; int fd; oid = lo_creat( pgConn, INV_READ | INV_WRITE ); fd = lo_open( pgConn, oid , INV_WRITE ); lo_open()…
Boris L
  • 171
  • 1
  • 7
1
vote
1 answer

PQescapeLiteral not defined?

This is about the most basic libpq example I could think of to illustrate my problem. The goal here is just to print out the escaped string. #include #include #include using namespace std; int main(){ …
KeatsKelleher
  • 10,015
  • 4
  • 45
  • 52
1
vote
2 answers

Getting sizeof(PGconn) with libpq

I'm attempting to wrap libpq for a program, and part of the FFI tool I'm using attempts to get sizeof() any struct in use. In this case the issue is that trying to get sizeof(PGconn) results in a bunch of errors from GCC because it is an incomplete…
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
1
vote
0 answers

php 5.3 compilation failed using postgresq93-devel into Docker image

I am using a custom compilation based on PHP 5.3 and I need to upgrade the postgresql version from 9.2 to 9.3. I am using docker for my infrastructure and the new lines I added was yum remove postgresql -y && \ rpm -i /tmp/postgresql93.rpm &&…
Robert
  • 10,403
  • 14
  • 67
  • 117
1
vote
1 answer

libpq only inserts first character in string column

So I have this structure in my psql table called rooms: Table "public.rooms" Column | Type | …
IvRRimUm
  • 1,724
  • 3
  • 21
  • 40
1
vote
1 answer

undefined reference to `PQconnectdb'

Recently a project that i am working on requred to add postgresql support to it. Project is written in C(its open sourceJanus gateway). I follwed these steps to install the postgress and libps-dev. sudo apt-get install postgresql sudo apt-get…
IvRRimUm
  • 1,724
  • 3
  • 21
  • 40
1
vote
2 answers

how to compile C code with pthread and lpq

I have been trying to compile a very simple code that contains postgres, pthread and mutexes. now when I do it with pthread alone every thing is fine, same when I do it with postgress alone! but when I try to compile the complete code I'm running…
Omid S.
  • 731
  • 7
  • 15
1
vote
0 answers

PostgreSQL connect timeout recommendations

I found this at official postresql documentation page connect_timeout Maximum wait for connection, in seconds (write as a decimal integer string). Zero or not specified means wait indefinitely. It is not recommended to use a timeout of less…
1
vote
1 answer

How to connect to postgresql from ios9

I'm building iOS9.3 app with Swift. I'm trying to connect the PostgreSQL directly, and yes I know usually the most common approach is to create a web api as bridge between apps and server(like MSSQL,PGSQL,MYSQL...), and that is the easy/safe way to…
tim_hong
  • 11
  • 5
1
vote
1 answer

Closing fd returned from _open_osfhandle without closing underlying handle

I have a program using libpq on windows, and I use _open_osfhandle(PQsocket(cnxn), 0) so that I can call select() on it. My problem is, libpq is closing the underlying socket in PQfinish() so I get assert failures when calling _close() on the value…
user4548445
1
vote
1 answer

Efficiency of opening PostgreSQL database connections

We have a PostgreSQL database to store our C++ application's data, and we use libpqxx to connect to it. Currently, we open a new pqxx::connection for each transaction we'd like to run. In deployment, we expect to execute at most probably about four…
villapx
  • 1,743
  • 1
  • 15
  • 31