pl/perl function life and variable scope - concurrency problem?

From: Christopher Murtagh <christopher(dot)murtagh(at)mcgill(dot)ca>
To: postgres general <pgsql-general(at)postgresql(dot)org>
Subject: pl/perl function life and variable scope - concurrency problem?
Date: 2003-11-12 20:05:34
Message-ID: 1068667533.879.105.camel@mafalda.murtagh.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2003-11-12 20:13:39 Re: using NOLOCK cause Cartesian joins
Previous Message Scott Chapman 2003-11-12 19:46:44 Re: SQL-question: returning the id of an insert querry