Re: Transactional issue that begs for explanation - Mailing list pgsql-novice

From Tom Lane
Subject Re: Transactional issue that begs for explanation
Date
Msg-id 5703.1284171784@sss.pgh.pa.us
Whole thread Raw
In response to Transactional issue that begs for explanation  (Mladen Gogala <mladen.gogala@vmsinfo.com>)
Responses Re: Transactional issue that begs for explanation
List pgsql-novice
Mladen Gogala <mladen.gogala@vmsinfo.com> writes:
> To make the story more interesting, I added the following:

> CREATE or REPLACE FUNCTION logtrg() RETURNS trigger AS $$
> open(STDOUT,">>/tmp/logfile") or die("Cannot open log:$!\n");
> $key=$_TD->{old}{key};
> $val=$_TD->{old}{val};
> print "Firing on: $key $val\n";
> return;
> $$ LANGUAGE plperlu;

I suspect you're shooting yourself in the foot by repeatedly re-opening
the backend's stdout and not fflush'ing anywhere along the line: somehow
the data going to the log file is getting mangled.  I don't see any
strange behavior here when using a less dangerous logging technique,
such as

CREATE or REPLACE FUNCTION logtrg() RETURNS trigger AS $$
$key=$_TD->{old}{key};
$val=$_TD->{old}{val};
elog(NOTICE, "Firing on: $key $val\n");
return;
$$ LANGUAGE plperlu;

(Actually, I don't see anything funny when using your original version
of the function, either; but it's probably dependent on a lot of
platform-specific libc details exactly how you got that result.)

            regards, tom lane

pgsql-novice by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: PostgreSQL article online - PDF
Next
From: Mladen Gogala
Date:
Subject: Re: Transactional issue that begs for explanation