From: | pgsql-bugs(at)postgresql(dot)org |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Bug #465: Program terminates with "Broken pipe" after PQexec (...) |
Date: | 2001-09-21 15:58:58 |
Message-ID: | 200109211558.f8LFww647837@hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Roland Baum, MD-SOFT (roland(dot)baum(at)md-soft(dot)net) reports a bug with a severity of 1
The lower the number the more severe it is.
Short Description
Program terminates with "Broken pipe" after PQexec (...)
Long Description
A self-written program terminates after a 2nd PQexec (...).
The programm makes a connection to the PostgreSQL-DB before any query is send.
The query-function is a authentication in the database.
but, after the 2nd call of PQexec (..) in the authenification-function, the programm terminates with a "broken pipe".
The mashine, the program & DB runs, is a RedHat Linux from Cobalt (now: Sun).
The _same_ code runs under a SuSE-Linux with Postgres and C++ PERFECT and i have no idea, where the problem is!
about the program:
the software is written in C++ and uses POSIX-threads under Linux.
there are a some permantent server-threads, which make the queries to the DB...
the program links via -lpq .
we hope for a fast answer
(please, excuse my bad english :-)) )
r.
Sample Code
#include <stdarg.h>
#include <string>
#include <pgsql/libpq-fe.h>
int authenticated (const char* host, const char* name, const char* sid) {
// Connect to DB
PGconn* conn;
host="";
if (host != "") {
conn = PQsetdbLogin (host, "5432", NULL, "pts/1", "netcom",
"postgres", "");
} else {
conn = PQsetdbLogin(NULL, "5432", NULL, NULL, "mdcomm",
"postgres", "");
}
if (PQstatus(conn) == CONNECTION_BAD) {
return (-1);
}
string query;
PGresult* queryresult;
// build the query
query = "SELECT * FROM isconnected, commuser WHERE nick=lower('";
query += name;
query += "') AND sid='";
query += sid;
query += "' AND commuser.uid=isconnected.uid";
// execute the query
// on this call, the programm dies with "broken pipe"
queryresult = PQexec(conn, query.c_str());
// if the user exists, the result contains the data
if (isconnected == true) {
query = "SELECT chatrechte FROM commuser, chatuser WHERE
nick=lower('";
query += name;
query += "') AND commuser.uid=chatuser.uid";
queryresult = PQexec (conn, query.c_str());
query = PQgetvalue (queryresult, 0, PQfnumber (queryresult,
"chatrechte"));
// convert string to int
int wert = atoi(query.c_str());
PQfinish(conn);
return wert;
} else {
PQfinish(conn);
return -1;
}
No file was uploaded with this report
From | Date | Subject | |
---|---|---|---|
Next Message | pgsql-bugs | 2001-09-21 23:01:02 | Bug #466: Unable to remove /root/tmp/initdb:xxxx.xxx |
Previous Message | Zhang Xiaoming | 2001-09-21 09:39:22 | bug! in 7.1.3 (for recursion function) |