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

PQexecParams failure using single quotes

I'm trying to insert into my SQL database using libpq with the following code: void func(PGconn *conn) { const char * params[2] = { "1", "\'POINT(0 0)\'" }; res = PQexecParams(conn, "INSERT INTO drive_test_point (id, geom) VALUES…
Civing
  • 353
  • 3
  • 12
1
vote
2 answers

Returning the error details to the calling function after catching an exception in Postgresql

I'm adding exception handling to PostgreSQL stored procedures in order to automatically rollback the transactions after an error occurs. My problem is that once I catch the exception, then I cannot return the details of the error to the calling C…
nib0
  • 61
  • 1
  • 5
1
vote
0 answers

Most efficient path for determining schema, table, and column name for query result fields?

Based on getting a query result field's table Oid and column number from PQftable() and PQftablecol(), what's the most efficient path to getting the schema name, table name, and column name for each field? (This is in the context of a tool running…
seth
  • 1,647
  • 1
  • 12
  • 20
1
vote
1 answer

DBD::Pg slow to connect to Postgresql on Mac OS

After some updates (system and brew - I don't know which was the cause), Perl's DBD:Pg is slow to establish a connection to a local Postgresql instance. It is not slow to execute queries once the connection has been established. No other utility…
Mike Bennett
  • 266
  • 3
  • 10
1
vote
3 answers

how to pass json in postman -> form-data

I have an application written in go, gin and libpq this application connects to an azure storage account, and can list containers/blobs, delete blobs and create new blobs the problem is when I need to insert new blobs, when inserting the blobs in…
1
vote
1 answer

Null values ​- Golang, libpq, postgresql

I have an application written in go, gin and libpq (postgresql).. I'm working on a pretty big framework, and I'm crud on one of the tables in that framework.. my problem is in the GET method of the application, more specifically in a uuid field,…
1
vote
1 answer

What is the difference in PostgreSQL between int2vector and int2array?

I have been looking around in the documentation, but could not find an explanation of what the "int2vector" type really is. It is found in some system tables like pg_trigger, but that's all a documentation search returns... It seems to be vaguely…
Eric Grange
  • 5,931
  • 1
  • 39
  • 61
1
vote
1 answer

Extended Query Protocol in Psycopg2

Does Psycopg2 support Extended Query Protocol ? If yes, can you please share documentation on how to use this mode?
Gaurav Jha
  • 161
  • 1
  • 7
1
vote
0 answers

Is there any use for the pg_type type?

Is there any real world use for the type pg_type, i.e type ids 71 and 210. Although it's a bit of a faff, queries can result in this type output, as in the below where an explicit cast to pg_type is used. SELECT ( 1,'The…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
1
vote
0 answers

libpq SELECT loop and UPDATE within the loop

I have a C++ program that does something like the following: PGresult* res = PQexec(conn, "SELECT id, foo FROM tbl WHERE some_condition"); for (int r = 0; r < PQntuples(res); ++r) { auto id = PQgetvalue(res, r, 0); auto foo = PQgetvalue(res,…
Joe Abbate
  • 1,692
  • 1
  • 13
  • 19
1
vote
1 answer

If calling PQfinish, is there any benefit of calling PQcancel?

If calling PQFinish, which "closes the connection to the server", is there any benefit to calling PQCancel beforehand? i.e. if the connection is closed, would the PostgreSQL server cancel any in-progress queries on this connection, just as it would…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
1
vote
1 answer

is it possible to connect to recovered host after failover using postgres libpq's multi-host connection string?

I have 2 db hosts: host1 and host2. I connect to db using multi host connection string: postgresql://host1:port1,host2:port2/. According to libpq documentation, connection is established with first successful host in the list given. When both hosts…
Rohanil
  • 1,717
  • 5
  • 22
  • 47
1
vote
0 answers

Can't link libpqxx in g++

MacOS 12.2.2, clang 13.0.0, XCode developer tools are installed. libpqxx was installed with the homebrew and can be found with include, but the linker cannot find the library. > g++ main.cpp -lpq -lpqxx -I/opt/homebrew/include -std=c++2a ld: library…
const
  • 11
  • 1
1
vote
0 answers

Postgres 13 fails at the initdb stage

I've followed the official installation instructions for my Centos 7 machine: # Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install…
joe
  • 305
  • 1
  • 4
  • 9
1
vote
1 answer

Efficient row reading with libpq (postgresql)

This is a scalability related question. We want to read some rows from a table and, after processing some of them, stop the query. The stop criteria is data dependent (we do not know in advance how many or what rows are we interested in). This is…
user2369060
  • 791
  • 6
  • 6