[BUGS] Bug #465: Program terminates with "Broken pipe" after PQexec (...)

2001-09-21 Thread pgsql-bugs

Roland Baum, MD-SOFT ([EMAIL PROTECTED]) 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 
#include 
#include   

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


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[BUGS] Bug #466: Unable to remove /root/tmp/initdb:xxxx.xxx

2001-09-21 Thread pgsql-bugs

Vladimir Georgiev ([EMAIL PROTECTED]) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Unable to remove /root/tmp/initdb:.xxx

Long Description
I've tried to follow the detailed description in INSTALL as for fresh install as long 
as it was possible.

0)My Linux box: Mandrake 8.0 for i586. Any RPMS concerning any RDBMSs were 
intentionally NOT installed during the Mandrake installation. PostgreSQL 7.1.3 source 
unpacked into /usr/src/postgresql-7.1.3. The root user enters this directory. Then:

1)
root# ./configure --with-perl --enable-odbc --enable-syslog
Result: Worked fine

2)
root# gmake
Result: Worked fine

3)
root# gmake install
Result: Worked fine

4)
root# adduser -r -d /dyn/pgsql/home postgres
Result: Failed. User postgres already exists.

5)
root# chown -R postgres.postgres *
Result: Worked fine

6)
user root edits /etc/ld.so.conf adding the line:
/usr/local/pgsql
Save the file and close it.

7)
root# ldconfig
Result: Worked fine

8)
user root edits /etc/profile adding
PATH=$PATH:/usr/local/pgsql/bin
export $PATH
MANPATH=$MANPATH:/usr/local/pgsql/man
export $MANPATH

9)
logout/login
Result: System variables set fine

10)
root# mkdir /dyn/pgsql
root# mkdir /dyn/pgsql/data
root# mkdir /dyn/pgsql/home
root# chown -R postgres.postgres /dyn/pgsql
Result: Worked fine

11)
root# usermod -d /dyn/pgsql/home
Result: Worked fine

12)
root# su postgres
Result: Worked fine

13)
postgres$ /usr/local/pgsql/bin/initdb -D /dyn/pgsql/data
Result: most of the script runs ok. At some point it said:
... unable to remove /root/tmp/initdb:xxx.xxx
where "xxx.xxx" are some numbers
Result:Failed
Observation: There are files created in /dyn/pgsql/data

14)
postgres$ /usr/local/pgsql/bin/pg_ctl -D /dyn/pgsql/data -l /dyn/pgsql/home/server.log 
start
Result: Failed. It said: Unable to remove /root/tmp/.
The server did not started.

==
How did I workarounded the problem
==

1) I've opened /dyn/pgsql/data/postgresql.conf
2) I've Uncommented the line 
#unix_socket_directory=''
so it became this:
unix_socket_directory='/tmp'
3) I've saved the so edited postgresql.conf.
4)
postgres$ /usr/local/pgsql/bin/pg_ctl -D /dyn/pgsql/data -l /dyn/pgsql/home/server.log 
start

RESULT: NOW IT WORKS FINE :-)

=
WHY do I think it's a bug
=
Because I've followed the commands order recommended by the INSTALL file as long as it 
was possible.
I've installed already about 4 prior versions of PostgreSQL, every time working this 
same way and never had this problem, every time working on some Mandrake distribution.

Sample Code


No file was uploaded with this report


---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Re: [BUGS] Bug #466: Unable to remove /root/tmp/initdb:xxxx.xxx

2001-09-21 Thread Peter Eisentraut

> Vladimir Georgiev ([EMAIL PROTECTED]) reports a bug with a severity of 3

> postgres$ /usr/local/pgsql/bin/initdb -D /dyn/pgsql/data
> Result: most of the script runs ok. At some point it said:
> ... unable to remove /root/tmp/initdb:xxx.xxx
> where "xxx.xxx" are some numbers
> Result:Failed
> Observation: There are files created in /dyn/pgsql/data

Initdb doesn't produce that kind of output.  Please post the exact output
you got.  And what do you have set for $TMPDIR?

> postgres$ /usr/local/pgsql/bin/pg_ctl -D /dyn/pgsql/data -l 
>/dyn/pgsql/home/server.log start
> Result: Failed. It said: Unable to remove /root/tmp/.

pg_ctl doesn't produce that kind of output.  Please post the exact output
you got.

> 1) I've opened /dyn/pgsql/data/postgresql.conf
> 2) I've Uncommented the line
> #unix_socket_directory=''
> so it became this:
> unix_socket_directory='/tmp'
> 3) I've saved the so edited postgresql.conf.
> 4)
> postgres$ /usr/local/pgsql/bin/pg_ctl -D /dyn/pgsql/data -l 
>/dyn/pgsql/home/server.log start
>
> RESULT: NOW IT WORKS FINE :-)

That is a completely incomprehensible workaround, but since you didn't
post the exact outputs above I cannot guess what actually happened here.

-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [BUGS] WAL Log numbering

2001-09-21 Thread Bruce Momjian


Attached is a patch that changes "sequential" to "ever-increasing".

> Justin Clift <[EMAIL PROTECTED]> writes:
> > I would have though that after 00FE would be
> > 0100, not 0001.
> 
> This is the intended behavior, I believe.  The low-order half is a
> 32-bit byte offset DIV XLogSegSize --- we could compress out the zero
> bits, but only at the cost of wiring an assumption about XLogSegSize
> into the filename format.  The reason that 0/FF is missing from the
> sequence is stated in xlog.h:
> 
> /*
>  * We break each logical log file (xlogid value) into 16Mb segments.
>  * One possible segment at the end of each log file is wasted, to ensure
>  * that we don't have problems representing last-byte-position-plus-1.
>  */
> #define XLogSegSize   ((uint32) (16*1024*1024))
> #define XLogSegsPerFile (((uint32) 0x) / XLogSegSize)
> #define XLogFileSize  (XLogSegsPerFile * XLogSegSize)
> 
> > Just checked through the Interactive docs (not sure which version of 7.1
> > they are) and says the numbers should be sequential.
> 
> This would seem to be an oversimplification in the docs.
> 
>   regards, tom lane
> 
> ---(end of broadcast)---
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026


Index: doc/src/sgml/wal.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/wal.sgml,v
retrieving revision 1.9
diff -c -r1.9 wal.sgml
*** doc/src/sgml/wal.sgml   2001/09/09 23:52:12 1.9
--- doc/src/sgml/wal.sgml   2001/09/22 03:58:39
***
*** 137,143 
 divided into 8 kB pages. The log record headers are described in
 access/xlog.h; record content is dependent on
 the type of event that is being logged.  Segment files are given
!sequential numbers as names, starting at
 .  The numbers do not wrap, at
 present, but it should take a very long time to exhaust the
 available stock of numbers.
--- 137,143 
 divided into 8 kB pages. The log record headers are described in
 access/xlog.h; record content is dependent on
 the type of event that is being logged.  Segment files are given
!ever-increasing numbers as names, starting at
 .  The numbers do not wrap, at
 present, but it should take a very long time to exhaust the
 available stock of numbers.



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster