pl/perl function life and variable scope - concurrency problem? - Mailing list pgsql-general

From Christopher Murtagh
Subject pl/perl function life and variable scope - concurrency problem?
Date
Msg-id 1068667533.879.105.camel@mafalda.murtagh.name
Whole thread Raw
Responses Re: pl/perl function life and variable scope - concurrency problem?  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List pgsql-general
 Greetings,

 Thanks to a lot of help on this list, I've managed to get my pl/perl
function working. However, I have an unexpected result. Here's a simple
way to reproduce this problem:

CREATE or REPLACE FUNCTION perltest(integer)
returns integer as '
  $MyInt = $MyInt + 1;
  return $MyInt;
' language plperlu;


Executing it produces:

chris=# select perltest(1);
 perltest
----------
        1
(1 row)

chris=# select perltest(1);
 perltest
----------
        2
(1 row)

chris=# select perltest(1);
 perltest
----------
        3
(1 row)

chris=# select perltest(1);
 perltest
----------
        4
(1 row)

 Doing the right thing and initialzing variables before using them
solves this. Should I worry about this? Are concurrent callings of this
function protected from each other?

 Any info would be much appreciated.

Cheers,

Chris


--
Christopher Murtagh
Enterprise Systems Administrator
ISR / Web Communications Group
McGill University
Montreal, Quebec
Canada

Tel.: (514) 398-3122
Fax:  (514) 398-2017

pgsql-general by date:

Previous
From: Hans-Jürgen Schönig
Date:
Subject: Re: [HACKERS] Proposal for a cascaded master-slave replication system
Next
From: Greg Stark
Date:
Subject: Re: using NOLOCK cause Cartesian joins