libpq bug? (I guess not)

Started by Yasuo Ohgakiabout 25 years ago4 messagesgeneral
Jump to latest
#1Yasuo Ohgaki
yasuo_ohgaki@hotmial.com

Hello all,

I need feedback from you!
I would like to make sure no one on this list did not experience following
problem in order to find what's wrong with my system.

OS: RedHat 7.0.1/ja (+ RedHat's glibc,gcc update RPM)
PostgreSQL: 7.0.3 (no additional patches, compiled from source. 32KB page size)
PHP: 4.0.4pl1 as Apache 1.3.19 DSO (These are compiled from source) TCP
connection to PostgreSQL Server.

I believe PHP4 uses libpq, so I would like to know if anyone experiences
following problem with libpq (or others like psql)

A query is executed multiple times, even if it suppose to do it once.

I have a PHP code to execute query like

$db = pg_pconnect('db=my_db host=localhost user=username');
$query = "INSERT INTO new_user (username, email, ............) VALUES ('ABC',
'foo@example.com', ..........);";
pg_exec($db, $query); // Execute query using database connection $db.

in my script. The script seems executing the query 4 times whenever it's called,
since I get 4 newly inserted records everytime execute the script. Usually, PHP4
will not do that. It executes query exactly once as it should be.
(There is no loop, of course. It's a rather simple registration script and have
no loop around pg_exec(). I even checked by printing letters to see if code
around pg_exec() is executed multiple times. PHP does not call print() multiple
times, so the problem should be at the line where pg_exec() is executed)

Does anyone have this problem with libpq? psql? or others?
If you do, please let me know.
(If you know what could be the cause, please let me know too)

Thanks a lot.
--
Yasuo Ohgaki

#2Mitch Vincent
mitch@venux.net
In reply to: Yasuo Ohgaki (#1)
Re: libpq bug? (I guess not)

pg_pconnect is very nasty right now (check the PHP bug list [bugs.php.net]
and you'll see many references to it).. They've said that the problems have
been (or are being) fixed for the next release of PHP but from what I
understand the PHP release won't be for a while.

Good luck!

-Mitch
Software development :
You can have it cheap, fast or working. Choose two.

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Yasuo Ohgaki" <yasuo_ohgaki@hotmial.com>
Cc: <pgsql-general@postgresql.org>
Sent: Tuesday, April 03, 2001 2:45 PM
Subject: Re: libpq bug? (I guess not)

"Yasuo Ohgaki" <yasuo_ohgaki@hotmial.com> writes:

I have a PHP code to execute query like

$db = pg_pconnect('db=my_db host=localhost user=username');
$query = "INSERT INTO new_user (username, email, ............) VALUES

('ABC',

'foo@example.com', ..........);";
pg_exec($db, $query); // Execute query using database connection $db.

in my script. The script seems executing the query 4 times whenever it's

called,

Show quoted text

since I get 4 newly inserted records everytime execute the script.

You could get some more info about what's happening by turning on query
logging in the postmaster (start postmaster with -d2, and be sure NOT to
use -S). But I'll bet that some way or other, PHP is submitting the
same query multiple times.

I have some recollection that pg_pconnect() doesn't behave very well;
you might need to avoid that in favor of a plain connect. Check the
archives for discussion of pconnect.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Yasuo Ohgaki (#1)
Re: libpq bug? (I guess not)

"Yasuo Ohgaki" <yasuo_ohgaki@hotmial.com> writes:

I have a PHP code to execute query like

$db = pg_pconnect('db=my_db host=localhost user=username');
$query = "INSERT INTO new_user (username, email, ............) VALUES ('ABC',
'foo@example.com', ..........);";
pg_exec($db, $query); // Execute query using database connection $db.

in my script. The script seems executing the query 4 times whenever it's called,
since I get 4 newly inserted records everytime execute the script.

You could get some more info about what's happening by turning on query
logging in the postmaster (start postmaster with -d2, and be sure NOT to
use -S). But I'll bet that some way or other, PHP is submitting the
same query multiple times.

I have some recollection that pg_pconnect() doesn't behave very well;
you might need to avoid that in favor of a plain connect. Check the
archives for discussion of pconnect.

regards, tom lane

#4Homayoun Yousefi'zadeh
homayounyz@home.com
In reply to: Yasuo Ohgaki (#1)
Problem starting postmaster

Hello there,

I am migrating from MySQL to PostgreSQL.
I have built pgsql 7.0.3 on Redhat 7.0.
All of the nevironmental variables have been
set properly. When I try to start the database
server using the following

bash-2.04$ /usr/local/pgsql/bin/postmaster

I get

IpcMemoryCreate: shmget failed (Identifier removed) key=5432010,
size=144, permission=700
This type of error is usually caused by an improper
shared memory or System V IPC semaphore configuration.
For more information, see the FAQ and platform-specific
FAQ's in the source directory pgsql/doc or on our
web site at http://www.postgresql.org.
IpcMemoryIdGet: shmget failed (Identifier removed) key=5432010,
size=144, permission=0
IpcMemoryAttach: shmat failed (Invalid argument) id=-2
FATAL 1: AttachSLockMemory: could not attach segment

I have read the docs. The only probable cause is the
lack of SYS V IPC support or small size of configured
shared memory in the kernel. However, neither one of
these suggestions applies to my case. I have even tried

bash-2.04$ /usr/local/pgsql/bin/postmaster -B 64

and the problem still persists.

Can somebody shed some light here?

Thanks,
HY