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
2
votes
1 answer

What would happen if a process established multiple PostgreSQL connections and terminated without closing them?

I'm writing a DLL for a purchased software. The software will perform multi-threaded calculations on certain tasks. My job is to output the relative result into a database. However, due to the limited support of the software, it is kind of difficult…
Shore
  • 827
  • 9
  • 24
2
votes
1 answer

How to execute an async Query with libpq

I want to execute a SQL query with libpq in a non-blocking fashion. Thus I want to be notified when my query has finished executing. As I understand this is supported by libpq if I use the asynchronous api. With the PQsendQuery function I can send…
Arwed Mett
  • 2,614
  • 1
  • 22
  • 35
2
votes
1 answer

PostgreSQL return an Array or Record as a Row

I'm trying to return a variable with a PostgreSQL function that returns row/rows so I can use libpqxx on the client side to iterate over it for example using: for (pqxx::result::const_iterator row = result.begin(); row != result.end(); row++) { …
TalG
  • 677
  • 1
  • 9
  • 26
2
votes
1 answer

Why is programming interface to database called driver?

When writing an application which updates or queries a database, we use something called a database driver (e.g. a JDBC driver). I wonder why it is called a driver instead of a library? Is libpq a driver too?
user3284469
2
votes
2 answers

Install libpq dependency with CMake

I'm building a program with CMake on Windows. The program has a dependency on libpq that's che C PostgreSQL library. I load the PostgreSQL package, CMake find it and the program it's built. But then I want to copy libpq.dll and its dependencies on…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
2
votes
2 answers

PQsetSingleRowMode low performance

I am currently implementing an adapter for PostgreSQL using libpq, and I was wondering if the single-row mode as set through PQsetSingleRowMode (https://www.postgresql.org/docs/9.6/static/libpq-single-row-mode.html) was having known performance…
Eric Grange
  • 5,931
  • 1
  • 39
  • 61
2
votes
0 answers

PostgreSQL performance using libpq/libpqtypes - multi line inserts

I am writing an application to read realtime data in an embedded environment and chuck it into a PostgreSQL 9.6 database. The data consists of a header with meta data including a timestamp and 200 unsigned chars containing values. the 200 values are…
SteamedUp
  • 131
  • 2
  • 8
2
votes
2 answers

"Relation does not exist" error, only with libpq

I'm trying to run this query to insert new row to Users table from my C code using PQexec() (libpq) INSERT INTO Users VALUES (( SELECT MIN(s.id) FROM generate_series(1,( SELECT GREATEST(MAX(Id) + 1,1) FROM Users )) AS s(id) WHERE NOT EXISTS…
Vlad Keel
  • 372
  • 2
  • 13
2
votes
1 answer

ImportError: /lib/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib/libpq.so.5)

I have to run a tornado webapp on a server using psycopg2 with postgresql as backend. I am working on Red Hat Enterprise Linux Server release 6.5. I set up a virtual environment. Now, on this server, i don't have root access, i can't use pip or yum…
cppnoob
  • 129
  • 1
  • 4
  • 12
2
votes
1 answer

libpq native extension crashed on ruby on rails

i'm trying to install pg ( postgreSQL gem ) on my Mac and got this error Installing pg 0.18.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory:…
Héctor León
  • 2,210
  • 2
  • 23
  • 36
2
votes
1 answer

Does the function PQinitOpenSSL need to be called with libpq?

I built the libpq static library using USE_SSL=1 option. The syntax used was: nmake.exe /f win32.mak USE_SSL=1 SSL_INC=C:\OpenSSL-Win32\include SSL_LIB_PATH=C:\OpenSSL-Win32\lib I am able to connect to DB server Using below command command…
2
votes
0 answers

How to get double value using libpq from Postgres

I am using libpq to connect to Postgres on Windows 10 using Visual Studio 2015, PostgreSQL9.4 I have a table like this: CREATE TABLE real_data ( plane_id integer NOT NULL PRIMARY KEY, timestamp integer NOT NULL, data1 double…
larryzhao
  • 3,173
  • 2
  • 40
  • 62
2
votes
1 answer

C libpq: get float value from numeric

I have a table with float value represented using numeric type. How can I get float value from this field using libpq lib? There is a specialized format for float type in postgres, but I have to work with existing database with numeric fields. I…
Sas
  • 523
  • 3
  • 21
2
votes
1 answer

Get libpq runtime version (from libpqxx)

In the libpqxx reference I can read sometimes stuff that is limited to the underlying libpq version ("Requires libpq version from PostgreSQL 7.4 or better. ") like here. Now the question(s): (1) How to obtain the libpq version used in the current…
550
  • 1,070
  • 1
  • 13
  • 28
2
votes
1 answer

Postgres libpq how to tell if a connection has been terminated

Given the following libpq code: PGconn * internalConnection = PQconnectdb("my connection string"); if (PQstatus(internalConnection) != CONNECTION_OK) { // return error on failure } // Kill all connections if(0 == PQsendQuery(internalConnection,…
Kyle
  • 17,317
  • 32
  • 140
  • 246