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
0 answers

Different methods of checking status of one libpq function

Is there somebody who can explain to me, why in postgresql libpq there are different methods of checking, whether an sql command was executed successfully or not (function "PQexec"). If your sql command in "PQexec" was a command returning no data…
Wolfgang Adamec
  • 8,374
  • 12
  • 50
  • 74
1
vote
1 answer

c++ application is crashing when allocating a const char* const buffer

I'm having trouble with creating a buffer in my c++ application. I am being forced to create a const char* const* buffer so that I can use libpq's PQexecParams function. PGresult *PQexecParams(PGconn *conn, const char *command, …
Kons
  • 73
  • 1
  • 7
1
vote
2 answers

how to call a pg function with libpq and get the param value

ALL I have a postgresql function,so this: CREATE OR REPLACE FUNCTION query_callouts( INOUT io_cursor_ref refcursor, INOUT opstatus integer, INOUT errtext character varying) RETURNS record AS $BODY$ DECLARE BEGIN OPEN $1…
1
vote
1 answer

How to dump PGresult

I am trying to debug my C program that accesses a postgres database. I would like to dump the contents of PGresult using some postgres provided routine. Is there a postgres provided routine that will dump PGresult in a human readable way? I will add…
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
1
vote
2 answers

PostgreSQL syntax error in parameterized query on "date $1"

Trying to parameterize my SQL queries (using libpq function PQexecParams), I was stuck on a syntax error: SELECT date $1 The error is: ERROR: syntax error at or near "$1"
1
vote
0 answers

JVM crashes with SIGSEGV in libpq.so

JVM crashes unexpectedly from time to time in our servers with SIGSEGV. We are using JNI to call some C functions which eventually use ECPG to talk to postgres db. Here is a stack trace for reference: Stack: [0xa895e000,0xa89af000], sp=0xa89ab550,…
Bibhu
  • 59
  • 1
  • 4
1
vote
1 answer

Thread safe PQconn object

I want to access a PostgreSQL table across a number of threads. How can I safeguard PQconn* object while multithreading? Does libpq library offer any method for this problem?
Kumar
  • 616
  • 1
  • 18
  • 39
1
vote
1 answer

PQgetResult always returns NULL

I'm writing a PostgreSQL library in Objective-C, based on libpq (written in C). While I've built a synchronous querying method that uses PQexec sucessfully; my asynchronous method never receives the query's results. PQgetResult always returns…
Jacob Budin
  • 9,753
  • 4
  • 32
  • 35
1
vote
1 answer

Undefined reference to PQfinish even though libraries etc. are included

I'm trying to compile a C++ application using libpq. On my Debian it compiles fine with the following command: g++ -I /usr/include/postgresql/ -L /usr/lib/postgresql/9.3/lib/ -lpq -o test test.cpp On my Ubuntu I get the following error: undefined…
user809829
  • 1,179
  • 3
  • 14
  • 33
1
vote
1 answer

How to delete a PGPing result from PostgreSQL's libpq?

I am using the c interface to PostgreSQL, libpq. If I do PQping() on the database, how do I free/delete the returned PGPing instance (to avoid memory leaks)? Is there something like PQclear() but for PGPing instead of PGresult?
user10607
  • 3,011
  • 4
  • 24
  • 31
1
vote
1 answer

Golang, postgres transaction: pq: unexpected transaction status in a failed transaction

Go: v 1.3 db: postgres using lib/pq I have an app that updates a postgres database. The postgres database is set up using pgbouncer. So, with an active connection I have code to run inserts and updates. Here is the insert code: func (sitemap…
nathj07
  • 685
  • 1
  • 11
  • 23
1
vote
3 answers

Link against a 3rd-party library with Visual Studio

I'm trying to create a .dll with Visual Studios 2013. The project includes libpq functionality. Per other stackoverflow posts, and other sources I've found on the internet, I've (as far as I'm aware) correctly added the postgres lib and include…
Tyler Sebastian
  • 9,067
  • 6
  • 39
  • 62
1
vote
2 answers

How do I insert this custom data type with libpq?

I'm having some difficulty with inserting some data using libpq. I have two custom data types: create type size as (width real, height real); create type rotated_rect as (angle real, center point, bounding_box box, size size) and I would like to…
user3791372
  • 4,445
  • 6
  • 44
  • 78
1
vote
2 answers

What does "cmd" in PQcmdTuples stands for?

I know what's this function do, but I can't find out a mnemonic for "cmd" in it. It wolud really helps me to remember this function name. Maybe someone knows? :)
user3616181
  • 975
  • 2
  • 8
  • 27
1
vote
1 answer

C++ How to use MIT Kerberos with libpq?

I have a windows c++ application which uses libpq to work with PostgreSQL. My code is: std::string conninfo = "host=localhost port=5432 dbname=test connect_timeout=10"; _connectionHandlerPtr = PQconnectdb(conninfo.c_str()); Now I need to use MIT…
ZedZip
  • 5,794
  • 15
  • 66
  • 119